Link to home
Start Free TrialLog in
Avatar of 7thwave
7thwave

asked on

Code for multiple select boxes in perl

what is the section of code for obtaining the data from a multiple select box.  I can get it to display the first value, but I need it to show all of the values selected.  The script is in perl.
Avatar of icd
icd

You don't state the script or module you are using to obtain the cgi variables. It is likely however that the script has put the multi-part data into a single variable (such as $in{myvar}) and separated them by the '\0' character. If this is the case then you can separate them with the following code.

@params = split ("\0", $in{myvar});

If this is not the case then let me know what cgi library/module you are using.

Avatar of ozo
I'd recommend CGI.pm:

#!/usr/bin/perl
use CGI qw(:standard);
print header;
print start_html('A Simple Example'),
      h1('A Simple Example'),
      start_form,
      checkbox_group(-name=>'words',
                     -values=>['eenie','meenie','minie','moe'],
                     -defaults=>['eenie','minie']),
      p,
      submit,
      end_form,
      hr;

if( param() ){
    print
        "The keywords are: ",em(join(", ",param('words'))),
        hr;
}
print a({href=>'http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html'},'Go to the documentation');

ASKER CERTIFIED SOLUTION
Avatar of yyyannag
yyyannag

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial