package MySample;
sub build_dropdown
{
# build_dropdown( \$DataObject , 'key_function', 'text_function', 'Select A Header', 'preselectedValue' );
my @xml;
if ( $_[3] )
{
push @xml , qq{};
push @xml , qq{};
}
foreach my $id ( $_[0]->{$_[1]}() )
{
my $sel = ( $id == $_[4] ) ? ' selected' : '';
push @xml , ("');
}
return join "\n" , @xml;
}
####
package myBox;
sub new
{
my $proto = $_[0];
my $class = ref($proto) || $proto;
my $self = bless ( {} , $class );
$self->{'__keys'} = { '1' => 'a', '2' => 'b', '3' => 'c', '4' => 'd', '5' => 'e' };
return $self;
}
sub get__keys
{
return keys %{ $_[0]->{'__keys'} };
}
sub get__textforkey
{
return $_[0]->{'__keys'}{$_[1]} ;
}
1;
####
my $box = myBox->new();
print &HtmlDropDowns::build_dropdown( $box , 'get__keys' , 'get__textforkey' , 'select a header' , 2 );