kmullin5016 has asked for the wisdom of the Perl Monks concerning the following question:
I am working with CGI.pm, and am having difficulties getting things to work, it may be a basic perl issue, or it may be something specific to CGI.pm. Here's what I am doing.
I want to use popup_menu to generate an HTML select. I can get this code to work just fine:
print $CGI->popup_menu(-name=>'menu_name', -values=>{'one'=>'eenie', 'two'=>'meenie', 'three'=>'minie'});
(where $CGI was created earlier with $CGI = new CGI;)
This works fine, so now I want to make the hash literal a has variable, so I try this:
%menu_values = {'eenie'=>'one', 'meenie'=>'two', 'minie'=>'three'}; print $CGI->popup_menu(-name=>'menu_name', -values=>%menu_values);
But what gets generated is this:
<select name="menu_name" > <option value="HASH(0x40132724)">HASH(0x40132724)</option> </select>
Huh? So I turn to my perl book "Learning Perl" published by O'Reilly, and see that it has hash literals in parens. Curious, but I try that, change my {} to (). But, now this is generated:
<select name="menu_name" three="meenie" one="minie" two> <option value="eenie">eenie</option> </select>
and I'm surprised that my browser even accepts it, but its not right. Please, what am I doing wrong?
Edit: g0n - code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: popup_menu CGI.pm problems
by liverpole (Monsignor) on Jan 19, 2007 at 16:19 UTC | |
|
Re: popup_menu CGI.pm problems
by kyle (Abbot) on Jan 19, 2007 at 16:13 UTC | |
|
Re: popup_menu CGI.pm problems
by davorg (Chancellor) on Jan 19, 2007 at 16:15 UTC | |
|
Re: popup_menu CGI.pm problems
by kmullin5016 (Acolyte) on Jan 19, 2007 at 17:46 UTC | |
by kyle (Abbot) on Jan 19, 2007 at 18:23 UTC | |
by kmullin5016 (Acolyte) on Jan 19, 2007 at 19:59 UTC | |
by kmullin5016 (Acolyte) on Jan 19, 2007 at 21:17 UTC | |
by kyle (Abbot) on Jan 19, 2007 at 22:02 UTC | |
|