Khalid Akram wrote:
> Hi,
> 
> I am having an issue using multiple checkboxes with the same name with TT.

Well firstly, this has nothing to do with TT!

> If I have some checkboxes like this:
> 
> <input type="checkbox" name="options" value="1">
> <input type="checkbox" name="options" value="2">
> <input type="checkbox" name="options" value="3">
> 
> If I select 3 of these and submit, what gets posted to the CGI is this:
> 
> options=1&options=2&options=3;

And that is exactly what you would expect, no? If not, you need to read
up about HTML forms.

> In my receiving script I have:
> 
> my $options = $query->param( "options" );
> 
> which only gives me the first value!! What I need is a comma separated list 
> that I can then loop over.
> 
> What is the best way around this?

You're using CGI.pm or some replacement, yes? (You don't say, so I have
to guess :( )

So if you look in its perldoc, it says:

"Pass the param() method a single argument to fetch the value of the
named parameter. If the parameter is multivalued (e.g. from multiple
selections in a scrolling list), you can ask to receive an array.
Otherwise the method will return a single value."

So it is behaving as it's supposed to, no? And what you need to do is
assign to an array instead of a scalar, to get the list of values.

Cheers, Dave

_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to