perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paweł Niewiadomski <niew...@widzew.net>
Subject Re: Multiple checkboxes with the same name
Date Sat, 19 Apr 2003 09:22:15 GMT
W liście z sob, 19-04-2003, godz. 02:33, Wim Kerkhoff pisze: 
> Paweł Niewiadomski wrote:
> 
> >I am using Embperl 1.3.4 in my website. I have the following problem:
> >Suppose I have the following page named checkbox.htm
> ><html>
> >   <body>
> >      <form action="checkbox.htm">
> >	 1<input type=checkbox name=cb value=1><br>
> >	 2<input type=checkbox name=cb value=2><br>
> >	 3<input type=checkbox name=cb value=3><br>
> >	 4<input type=checkbox name=cb value=4><br>
> >	 <input type=submit>
> >      </form>
> >   </body>
> ></html>
> >Now once I select one of the checkboxes, after I have clicked on submit
> >the checkbox stays checked as expected. If, however, I select multiple
> >checkboxes they are cleared after the page has reloaded. Is it possible
> >to somehow eliminate this problem? Theoretically I could split $fdat{cb}
> >into some array and then put an [- if (found_in_array(x)) {$fdat{cb}=x}
> >-], where x is the value of the following checkbox before every one of
> >them, but that looks pretty messy.
> >  
> >
> Here's the method that I use. Change the name of the checkboxes slightly:
> 
> <form action="checkbox.htm">
> 	b1<input type=checkbox name="cb:1" value=1><br>
> 	2<input type=checkbox name="cb:2" value=1><br>
> 	3<input type=checkbox name="cb:3" value=1><br>
> 	4<input type=checkbox name="cb:4" value=1><br>
> 	<input type=submit>
> </form>
> 
> Then, access them like this:
> 
> [-
>     @checks = grep {/cb:/} keys(%fdat);
>     s/cb://g for @checks;
> -]
> 
> Often checkboxes are used in a table where other columns might contain 
> selects, input fields, more checkboxes, and so on. By putting the row 
> sequence in the field name, order is preserved. Actually, in my example 
> above, the value for the checkboxes is never used. Instead, the value is 
> just so that it'll showed up as defined in %fdat.
> 
> HTH, YMMV
> 
> Wim
Thank you for your suggestion. That was actually what I was trying to 
avoid, because I wanted to do some processing with loops in JavaScript
(functions that would check or clear all the checkboxes). I have used
another trick to achieve this (dynamic generation of JavaScript code
with Embperl loops), but I was just wondering if that automatic checking
of multiple checkboxes with the same name should not be an option in
future releases of Embperl. It should not be very hard to achieve and
would be extremely useful in my opinion.
Greetings,
Paweł


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message