Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I need to pass all the selected items from a multi select box from one html page to another for searching a database. How do I get all the items in variables? Anyone help would be appreciated.

Replies are listed 'Best First'.
Re: multi select box
by davis (Vicar) on May 24, 2004 at 13:36 UTC
    Oh I see, you want us to write your code for you, without showing any effort on your part.....
    For reasons which escape me...
    #!/usr/bin/perl use warnings; use strict; use CGI; my $q = CGI->new; print $q->header, $q->start_html(-title=>"Monkies"); my @options = qw/Macaque Proboscis Invisible Lemur/; if($q->param("monkies")) { print "It looks like you selected the following symian friends +.<br />\n"; print join("<br />\n", $q->param("monkies")); } print $q->start_form; print $q->popup_menu(-name=>"monkies", -values=>\@options, -multiple=> +"multiple", -size=>"5"); print $q->submit(-value=>"Choose"); print $q->end_form; print $q->end_html;
    If there's anything there that you don't understand, I recommend checking Ovid's CGI course, and of course the manual for the lovely CGI module.
    Side note, you'd be better off using one of the templating modules rather than CGI's methods for generating HTML, but that's just an opinion

    davis
    It's not easy to juggle a pregnant wife and a troubled child, but somehow I managed to fit in eight hours of TV a day.
      Oh I see, you want us to write your code for you, without showing any effort on your part..... For reasons which escape me...
      Must be because there's always a sucker who does....

      Abigail

        Must be because there's always a sucker who does....
        Perhaps... but I was feeling charitable, and there's the slimmest of chances that providing examples with admonishment might lead the OP to learn something. After all, the code I provided is useless to anyone without modification.

        davis
        It's not easy to juggle a pregnant wife and a troubled child, but somehow I managed to fit in eight hours of TV a day.
        You guys crack me up. The fact is I have done work and searched a good bit for the answer but I suppose I was looking in the wrong place. Although I don't expect people to write code for me I do think it is very helpful if someone who wants to share their knowledge without all the "make you feel guilty" attitude just posts some code that they have already written. Remember, everyone was new at Perl at some point. If you did all the research yourself and never used anyone else's code then codos to you but my guess is that most everyone has used other people's code at some point. Anyway, to the one that greatly helped me with posting some code, thank you very very much!!!!!
Re: multi select box
by Abigail-II (Bishop) on May 24, 2004 at 13:24 UTC

      man CGI produces more output than a newbie could memorize in a hurry... and while reading the whole is a worthwhile exercise, seraching through it for "multiple" answers the question.

      Cheers, Sören

      I know that but I am looking for specific code for the multiselct box? How do I get the selections into an array?
        If you know the manual page, it would help if you could indicate which part of it is unclear to you. There's no point in quoting the text if you know it, and don't understand it.

        Abigail