For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > July 2004 > HTML::Form, Multiple select Elements with Same name









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author HTML::Form, Multiple select Elements with Same name
David Marshall

2004-07-30, 8:55 pm

Hi all,

I have a form that has multiple <select> elements that have the same
name. This is so that the destination script can deal with all of them
as an array. <select multiple> is not appropriate because the order in
which options are chosen is significant.

A simple version of the form might be

<form action="foo.pl" method="POST">
<select name="m">
<option>a
<option>b
<option>c
</select>
<select name="m>
<option>a
<option>b
<option>c
</select>
<input type="submit">
</form>

Works great. The handler script works wonderfully.

However, when I try to test it all with WWW::Mechanize, there's a
problem with HTML::Form, which parses it out to be (effectively) a
single select with 6 options.

I don't see anyway to make HTML/Form.pm parse this correctly without one
of several really unpleasant modifications. I don't want to have to
change the names of the <select> elements to be unique (e.g. m1, m2),
because then I'd have to add code to the handler script to put these
parameters into an array. I get that effect automatically with the
current naming.

Comments/thoughts/suggestions?
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com