Hi, am trying to I have a matrix of checkboxes in a form, something like this : rows col1 col2 col3 col4 row1 cb cb cb cb row2 cb cb cb cb row3 cb cb cb cb where "cb" is a checkbox the row and colum names are generated at runtime from some sql-methods the code for the form is something like this : <dtml-in rowsnamesmethod> <tr> <td><dtml-var rowname></td> <dtml-in columnsnamesMethod> <td align="center"> <input type="checkbox" name="<dtml-var rowname>" Value="<dtml-var columnname>"> </td> </dtml-in> so the question is : how can I reference the values of my checboxes in the result method ? if i write <dtml-in rowsnamesmethod> <dtml-var rowname> </dtml-in> it gives me the row names, but I need the values of a checbox named that way, i try <dtml-in rowsnamesmethod> <dtml-var <dtml-var <rowname>> </dtml-in> but that's a sintax error, what should i do ? Orlando Sanchez Sitecpro <dtml-
Use <dtml-sequence-item> to access each item in a list when you are interating through it using <dtml-in>. Conversely, <dtml-in> must be given a list to work with. To be certain of what your form is returning to Zope, look at the contents of the REQUEST by simple adding this to a plain page: <dtml-var "REQUEST.form"> You will see all the form variables. Braces {like this} are dictionaries (or hashes, if you prefer), brackets [like this] are lists. This will give you a list of all the name/value pairs in the form: <dtml-var "REQUEST.form.items()"> This will give you a list of all the field names in the form: <dtml-var "REQUEST.form.keys()"> If you have a key (that is, a field name in the form) of 'k1', you could get its value with <dtml-var "REQUEST.form['k1']> It's a little trickier if you are interating through the keys as in <dtml-in "REQUEST.form.keys"> <dtml-var "REQUEST.form[_['sequence-item']]"> </dtml-in> You have to do this little hack because you can't use a name like sequence-item inside double quotes (because python would try to subtract item from sequence). _['...'] is an alternate way to access a variable whose name is known to the current namespace. Finally, if you have more than one checkbox with the same name, for that field name you will get a list of all the values for all the boxes with that name. This should give you enough to figure out how to proceed. Just make sure to look at the form data first before doing any more coding. Cheers, Tom P [Orlando Sanchez] so the question is : how can I reference the values of my checboxes in the result method ? if i write <dtml-in rowsnamesmethod> <dtml-var rowname> </dtml-in> it gives me the row names, but I need the values of a checbox named that way, i try <dtml-in rowsnamesmethod> <dtml-var <dtml-var <rowname>> </dtml-in>
participants (2)
-
Orlando Sanchez -
Thomas B. Passin