Try this:
TABLE(*[TR('T',INPUT(_type="checkbox",_name='T'))]+\
[TR("Option "+str(opt), INPUT
(_type="checkbox",_name=opt,value=False,_value='on')) for opt in
options]+\
[TR("",INPUT(_type="submit",_value="SUBMIT"))])
On Dec 4, 9:02 pm, Maurice Ling <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> I have an issue with multiple checkboxes which can only be defined at
> runtime.
> Here is my sample code:
>
> options = range(5)
> def multi_input():
> form = FORM(
> TABLE(TR('T',INPUT(_type="checkbox",_name='T')),
> [TR("Option "+str(opt), INPUT
> (_type="checkbox",_name=opt,value=False))
> for opt in options],
> TR("",INPUT(_type="submit",_value="SUBMIT"))))
> opt_list = []
> if form.accepts(request.vars,session):
> ssession['form_vars'] = form.vars
> redirect(URL(r=request,f='multi_out'))
> return dict(form=form)
>
> def multi_out(): return dict(result=session['form_vars'])
>
> The list comprehension part ([TR("Option "+...for opt in options])
> gave me the correct number of checkboxes. However, when I submit the
> form, the information is not passed onto form.vars
>
> For example, if I check "T", "Option 1" and "Option 2", I get
> 1:
> 2:
> 3:
> 4:
> T:on
>
> Any idea how to pass the 'on' value for "1" and "2"?
>
> Thanks
> Maurice
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---