jpk236 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I'm having some issues processing a Multiple Select box with Perl, and who else better to leverage than the Monks!
HTML:
I've tried various ways of retrieving the data, and I either get nothing back or I only get back the last element.
Thanks for any help!
- Justin
I'm having some issues processing a Multiple Select box with Perl, and who else better to leverage than the Monks!
HTML:
Perl:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ +/www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Test Form</title> </head> <body> <form method="post" action="/cgi-bin/test_form.cgi"> Function:<br/> <br/> <select name="Blah[]" multiple="multiple"> <option value=""></option> <option value="Blah1">Blah1</option> <option value="Blah2">Blah2</option> <option value="Blah3">Blah3</option> <option value="Blah4">Blah4</option> <option value="Blah5">Blah5</option> </select> <br/><br/> <input type="submit" value=" Submit " /> </form> </body> </html>
This is what I thought would work.#!/usr/bin/perl -w use strict; my ($buffer, $pair, $var, $payload, $i); my (@pairs); my (%POST); read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($var, $payload) = split(/=/, $pair); $payload =~ tr/+/ /; $payload =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $POST{$var} = $payload; } foreach $i ($POST{Blah}) { print "Blah: ".$i."<br/>\n"; }
I've tried various ways of retrieving the data, and I either get nothing back or I only get back the last element.
Thanks for any help!
- Justin
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Processing a multiple="multiple" <select>
by Corion (Patriarch) on Sep 20, 2007 at 13:37 UTC | |
Re: Processing a multiple="multiple" <select>
by ikegami (Patriarch) on Sep 20, 2007 at 13:38 UTC | |
Re: Processing a multiple="multiple" <select>
by snopal (Pilgrim) on Sep 20, 2007 at 13:47 UTC | |
by jpk236 (Monk) on Sep 20, 2007 at 13:53 UTC | |
by snopal (Pilgrim) on Sep 20, 2007 at 14:13 UTC | |
Re: Processing a multiple="multiple" <select>
by jpk236 (Monk) on Sep 20, 2007 at 13:55 UTC |
Back to
Seekers of Perl Wisdom