awohld has asked for the wisdom of the Perl Monks concerning the following question:
Here's my HTML output from the code above#!/usr/bin/perl -wT use DBI; use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use Data::Dumper; my $cgi = CGI->new(); # Create new CGI object. my $database = "db"; my $db_server = "localhost"; my $user = "user"; my $password = "pass"; my $dbh = DBI->connect("DBI:mysql:$database;host=$db_server", $user, $password) or die $DBI::errstr; my $authorSQL = "SELECT idAuthor, Author FROM Author ORDER BY Author"; my $hash_ref = $dbh->selectall_hashref($authorSQL, "idAuthor"); print $cgi->header; print $cgi->start_form; print Dumper($hash_ref); print $cgi->popup_menu(-name=>'menu_name', -values=>[$hash_ref]); print $cgi->end_form;
As you can see from Data::Dumper, I need the drop down menu to show "Mike" and "Cecil" with their values 1 and 2 respectively.<form method="post" action="/cgi-bin/addlocation.pl" enctype="multipar +t/form-data"> $VAR1 = { '1' => { 'Author' => 'Mike', 'idAuthor' => '1' }, '2' => { 'Author' => 'Cecil', 'idAuthor' => '2' } }; <select name="menu_name" tabindex="1"> <option value="HASH(0xa278214)">HASH(0xa278214)</option> </select><div></div></form>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI's "popup_menu" Using Hash Reference
by pg (Canon) on Aug 31, 2005 at 06:16 UTC | |
|
Re: CGI's "popup_menu" Using Hash Reference
by fizbin (Chaplain) on Aug 31, 2005 at 09:22 UTC | |
|
Re: CGI's "popup_menu" Using Hash Reference
by duff (Parson) on Aug 31, 2005 at 06:13 UTC | |
by pg (Canon) on Aug 31, 2005 at 06:21 UTC |