Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: drop down menus

by Michalis (Pilgrim)
on Sep 21, 2000 at 14:56 UTC ( [id://33463]=note: print w/replies, xml ) Need Help??


in reply to drop down menus

If you use CGI.pm and IF you have assigned the values of the db in a hash named (for example) %myhash then what you want is :
start_form(-method=>'post', -action=>'youractionhere'), popup_menu(-name=>'yournamehere', -values=>\%hash), end_form;
you may also use a 'default' value. (man CGI.pm and look for popup_menu). Needless to say that the above code won't work on its own (it needs a new CGI and much more code, which I guess you know how to create).

Replies are listed 'Best First'.
RE: Re: drop down menus
by cianoz (Friar) on Sep 21, 2000 at 15:47 UTC
    -values needs an array reference (not an hash) so the right sintax is
    -values=>[sort keys %hash]
      Sorry, you're simply wrong.. What he needs is a hash reference: I copy/paste from the CGI.pm documentation: (in http://stein.cshl.org/WWW/software/CGI/cgi_docs.html)
      If you pass a HASH reference, the keys will be used for the menu values, and the values will be used for the menu labels.
        no, we are both right:-)
        (from http://stein.cshl.org/WWW/software/CGI/cgi_docs.html)

        The required second argument (-values) is an array reference containing the list of menu items in the menu. You can pass the method an anonymous array, as shown in the example, or a reference to a named array, such as \@foo. If you pass a HASH reference, the keys will be used for the menu values, and the values will be used for the menu labels (see -labels below).

        using an array reference has a little advantage:
        you have full control on how items are sorted...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://33463]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-25 22:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found