Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: CGI's "popup_menu" Using Hash Referenceby fizbin (Chaplain) |
on Aug 31, 2005 at 09:22 UTC ( [id://488049]=note: print w/replies, xml ) | Need Help?? |
The posters so far don't seem to have looked up the CGI perldoc before posting. In any case, in order to create a popup menu with labels different from the values, you need to be using both the -values parameter and the -labels parameter. This first of those takes a list reference, and the second a hash reference. So let's take a look at what they require. As it stands now, you're passing into -values a structure like this: when what you need to do is pass a structure like this as the -values parameter: [ '1', '2' ], and this as the -labels parameter: So the question is, how do you go from one to the other? As with many structure reformulations, the answer is with a clever use of map: If you don't like the order authors are shown in once you have ten or more, change the sort call above so that it sorts numerically.
--
In Section
Seekers of Perl Wisdom
|
|