[Zope] variable length forms...
Rik Hoekstra
rik.hoekstra@inghist.nl
Tue, 07 Nov 2000 12:05:21 +0100
zope wrote:
>
> Hi.
>
> I have tried to implement a variable length form.
>
> Yes, I have read
> http://www.zope.org/Members/jpenny/variable_length_forms/index_html.!
>
> I a form, I'm using following form fields:
>
> <dtml-in "_.range(1, _.string.atoi(form_numpages)+1, 1)">
> <tr align="center" valign="middle">
> <td><dtml-var sequence-number></td>
> <td><input type="text" name="form_time_out" size="6" maxlength="4"></td>
> <td><input type="radio" name="radiob<dtml-var sequence-number>"></td>
> <td><input type="radio" name="radiob<dtml-var sequence-number>"></td>
> </tr>
> </dtml-in>
>
> where form_numpages is a variable that i got from a previous form.
> This form works fine and generates me form_numpages lines with always one
> textfield and a group of 2 radiobuttons named per line.
>
> form_time_out radiob1 radiob1
> form_time_out radiob2 radiob2
> form_time_out radiob3 radiob3
> ...
>
> The contents of this form is submitted and I want to interpret the data
> with following method:
>
> 1: <dtml-in "_.range(1, _.string.atoi(form_numpages)+1, 1)">
> 2: <dtml-var sequence-number>:
> 3: <dtml-var "_['radiob'+_['sequence-number']]">
> 4: </dtml-in>
>
> This returns the following Zope error:
>
> Error Type: TypeError
> Error Value: illegal argument type for built-in operation
>
> If I'm replacing the third line with <dtml-var "_['sequence-number']">, the
> sequence-number is printed out. So I'm sure that it exits.
hm, sequence_number is an integer. You can't add that to a string, hence
the error.
try something like (untested):
3: <dtml-var "_['radiob%s' %_['sequence-number']]">
or
3: <dtml-var "_['radiob'+_.str(_['sequence-number'])]">
sorry for the ugly code ;-)
hth
Rik