package MySample;
sub build_dropdown
{
# build_dropdown( \$DataObject , 'key_function', 'text_function', 'Select A Header', 'preselectedValue' );
my ($obj, $key_f, $text_f, $header, $preselected) = @_;
my @xml;
if ( $header )
{
push @xml , qq{};
push @xml , qq{};
}
foreach my $id ( $obj->$key_f() )
{
my $sel = ( $id == $preselected ) ? ' selected' : '';
push @xml , ("');
}
return join "\n" , @xml;
}
####
print HtmlDropDowns::build_dropdown(undef,
sub { 1 .. 10 },
sub { shift; 'Entry ' . shift; },
'Pick a number from 1 to 10',
5,
);