getting all fields from dynamic checkboxes
Hi, Has anyone found a way to get a list of boolean values from dynamically created checkboxes. I have created a bunch of checkboxes within a repeat loop like this: <input type="checkbox" class="noborder" name="cb_array:list:int" tal:attributes="tabindex tabindex/next; checked python:test(curr_prop, 'checked', None);"> but when I access the cb_array from my python script, I only get the checked values (and I can no longer match the values up with the checkbox they came from). any help on this would be appreciated. thanks in advance, Dan
On Apr 4, 2005 9:00 AM, Dan E <dane1979@gmail.com> wrote:
Hi, Has anyone found a way to get a list of boolean values from dynamically created checkboxes. I have created a bunch of checkboxes within a repeat loop like this:
<input type="checkbox" class="noborder" name="cb_array:list:int" tal:attributes="tabindex tabindex/next; checked python:test(curr_prop, 'checked', None);">
but when I access the cb_array from my python script, I only get the checked values (and I can no longer match the values up with the checkbox they came from).
You need to keep a server-side list of the checkboxes and check which ones aren't there. Web browsers don't send back checkboxes that aren't checked - it's an HTML feature. -- Phillip Hutchings http://www.sitharus.com/ sitharus@gmail.com / sitharus@sitharus.com
Phillip Hutchings wrote:
You need to keep a server-side list of the checkboxes and check which ones aren't there. Web browsers don't send back checkboxes that aren't checked - it's an HTML feature.
Well, server side lists don't scale. I've found keeping a hidden html input with a list of the fields I'm expecting back can help, but bear in mind that makes it more hackable... cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Dan E wrote:
Hi, Has anyone found a way to get a list of boolean values from dynamically created checkboxes. I have created a bunch of checkboxes within a repeat loop like this:
<input type="checkbox" class="noborder" name="cb_array:list:int" tal:attributes="tabindex tabindex/next; checked python:test(curr_prop, 'checked', None);">
but when I access the cb_array from my python script, I only get the checked values (and I can no longer match the values up with the checkbox they came from).
any help on this would be appreciated. thanks in advance, Dan
Dan, Not really sure if this is what you want. But i've done stuff like: <form action="showRequest"> <tal:block repeat="num python: range(10)"> <input type="checkbox" class="noborder" tal:attributes="name python:'checkBox'+ str(num);"> </tal:block> <input type="submit" value="test me!"> </form> </body> When showRequest is called, it displays just the selected checkboxes like: checkBox0 'on' checkBox2 'on' checkBox4 'on' checkBox7 'on' hth, David
Dan E wrote at 2005-4-3 17:00 -0400:
Has anyone found a way to get a list of boolean values from dynamically created checkboxes. I have created a bunch of checkboxes within a repeat loop like this:
<input type="checkbox" class="noborder" name="cb_array:list:int" tal:attributes="tabindex tabindex/next; checked python:test(curr_prop, 'checked', None);">
but when I access the cb_array from my python script, I only get the checked values (and I can no longer match the values up with the checkbox they came from).
any help on this would be appreciated.
You may use the ":default" specifier with a hidden variable to provide a value when the browser does not sent one. <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> briefly describes the request variable specifier. -- Dieter
participants (5)
-
Chris Withers -
Dan E -
David H -
Dieter Maurer -
Phillip Hutchings