You need to handle this with jQuery.

One can have a single form with all fields you need and use jQuery to
show/hide fields based on values of other fields (*) OR you can have
multiple forms in the page and use jQuery to show/hide an entire form.

The action that generates the forms is executed twice (before the form
is submitted to generate the page, and after the form is submitted)
and therefor it what goes in the form cannot be decided at the web2py
level. Must be done at the client level.

(*) look into kpax views survey. It does that.

On Jan 24, 4:10 pm, oktay <onur.ok...@gmail.com> wrote:
> Hi,
>
> What I plan to do is, changing my form in my view according to
> selected option without pushing a button.
> I mean, when I change my option, the form must change. And by default
> first option is selected also... How can I change my below code to
> make it dynamic? Or do you have any suggestions?
>
> Assume I have a select box with options [x,y,z]
>
> def index():
>    values= ['x','y','z']
>    options = (TABLE(FORM(TR('Forms: ', SELECT
> (values,_name='values')))))
>
>    if request.vars.instrument=='x':
>        form = FORM(INPUT(_name='visitor_name',requires=IS_NOT_EMPTY
> ()),
>                             INPUT(_type='submit'))
>    if request.vars.instrument=='y':
>        form = FORM(INPUT(_name='visitor_name',requires=IS_NOT_EMPTY
> ()),
>                             INPUT
> (_name='visitor_name2',requires=IS_NOT_EMPTY()),
>                             INPUT(_type='submit'))
>   if request.vars.instrument=='z':
>        form = FORM(INPUT(_name='visitor_name2',requires=IS_NOT_EMPTY
> ()),
>                             INPUT
> (_name='visitor_name3',requires=IS_NOT_EMPTY()),
>                             INPUT(_type='submit'))
>
>    return dict(form=form, options=options)
>
> In my view:
> {{extend 'layout.html'}}
> {{=options}}
> {{=form}}
>
> Best wishes...

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to