in reply to Re^4: creating CGI::scrolling_list ... can this be shortened?
in thread creating CGI::scrolling_list ... can this be shortened?
Hi,
Try this:
#... use strict; use DBI; use CGI; #... my $statement = "SELECT id, display_name FROM membership ORDER BY disp +lay_name"; my $result = $dbh->selectall_arrayref($statement); my %h = map { $_->[0] => $_->[1] } @$result; my $cgi = new CGI; print $cgi->scrolling_list( -name => 'list_name', -multiple => 'true', -values => [ sort keys %h ], -labels=> \%h, ); #...
Read the man page of DBI, there is explain how the combination of -values and -labels work.
And don't forget to check the result of the statement.
Regards,
|
|---|