[San-Diego-pm] Passing multiple select options

Bob Kleemann rkleeman at energoncube.net
Fri Sep 14 16:05:09 PDT 2007


param in a scalar context ( in a context where only one value is expected )
returns one item, the first set item.  In a list context it returns multiple
items.  To fix your code below:

  die map {$_.' = '.join(', ', $co->param($_))."\n"}(@Param);


On Fri, Sep 14, 2007 at 03:24:27PM -0700, Joel Fentin wrote:
> After multiple options are selected and the submit button is clicked, I 
> can't get the mulitple options into the receiving code *if* the form 
> method is post.
> 
> If the form method is get, the needed data is contained in 
> $ENV{'QUERY_STRING'}.
> 
> If the form method is post, I don't know how to get it. I would prefer post.
> 
> The sending code:
> 
> #!/usr/bin/perl -w
> print "Content-type: text/html\n\n";
> print'
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <HTML>
> <HEAD>
> </HEAD>
> <BODY>
> <FORM ACTION="EditJob.pl"  METHOD="POST" 
> ENCTYPE="application/x-www-form-urlencoded">
> <TABLE BORDER CELLPADDING=5>
> <TR>
> <TD>
> <SELECT NAME="teams" MULTIPLE SIZE=6>
> <OPTION VALUE="b"          >blue</option>
> <OPTION VALUE="g"          >green</option>
> <OPTION VALUE="r"          >red</option>
> <OPTION VALUE="p"          >purple</option>
> <OPTION VALUE="f"          >fuschia</option>
> <OPTION VALUE="m"          >mango</option>
> </SELECT>
> <INPUT TYPE=SUBMIT VALUE="submit">
> </TD>
> </TR>
> </TABLE>
> </FORM>
> </body>
> </HTML>';
> 
> Some of the receiving code:
> 
> print "Content-type: text/html\n\n";
> my $key;
> foreach $key(keys %ENV){print "$key=$ENV{$key}\n"}
> my @Param = $co->param(); die map {$_.' = '.$co->param($_)."\n"}(@Param);
> 
> =========
> 
> perl perl perl
> 
> -- 
> Joel Fentin       tel: 760-749-8863
> Email:            http://fentin.com/me/ContactMe.html
> Biz Website:      http://fentin.com
> Personal Website: http://fentin.com/me
> _______________________________________________
> San-Diego-pm mailing list
> San-Diego-pm at pm.org
> http://mail.pm.org/mailman/listinfo/san-diego-pm


More information about the San-Diego-pm mailing list