http://qs321.pair.com?node_id=477359


in reply to creating CGI::scrolling_list ... can this be shortened?

Using much the same technique as described here:

my $sth = $dbh->prepare("SELECT id, display_name FROM membership ORDER + BY display_name"); $sth->execute; my %row; $sth->bind_columns( \( @row{ @{$sth->{NAME_lc} } } )); while ($sth->fetch) { my $memberWidget = $q->scrolling_list( -name => '...', -values => [ @row{sort keys %row}], -labels => \%row, ... ); push (@memberWidgets, $memberWidget); }

I'm not sure about the -values and -labels option of scrolling_list (as I've never used CGI built-ins) but this should get you started (and the keys aren't sorted but the order you get it from the database is the same).

"Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce

Replies are listed 'Best First'.
Re^2: creating CGI::scrolling_list ... can this be shortened?
by geektron (Curate) on Jul 22, 2005 at 23:58 UTC
    well, since you're not familiar with the CGI builtins, you're missing something very imporant ... you're creating N widgets ( where N is the number of rows returned ), not creating N options in the scrolling list.

    i'm sure something more like a Scwartzian Transform in the original  map would do it...