Conditional fields

31 views
Skip to first unread message

Bishal Saha

unread,
Jan 16, 2017, 11:01:52 PM1/16/17
to web2py-users
I am trying to create a form which will have multiple forms and where the first form will have two radio buttons and one of them will work like - if it is selected then all the other fields of the other forms wont show and directly we can submit the whole form with null values to the other fields of the other forms and with just one value to the one table for that one form in the data base whereas when the other radio button is selected we can fill in the others fields of the other forms in that form . Any suggestions please , I am stuck here for days now.

Dave S

unread,
Jan 17, 2017, 3:04:29 AM1/17/17
to web2py-users
On Monday, January 16, 2017 at 8:01:52 PM UTC-8, Bishal Saha wrote:
I am trying to create a form which will have multiple forms and where the first form will have two radio buttons and one of them will work like - if it is selected then all the other fields of the other forms wont show and directly we can submit the whole form with null values to the other fields of the other forms and with just one value to the one table for that one form in the data base whereas when the other radio button is selected we can fill in the others fields of the other forms in that form . Any suggestions please , I am stuck here for days now.

That sounds like a job for client-side javascript.  That would involve event handlers.  It's easy enough to add a script section to a view; I've done that with one of my forms to make the next input field be based on the value of the first input field.  (I've used the jquery environment to do that, but if you don't know javascript at all, a good basic course should cover the "native" event handlers.  I don't have a recommendation for self-study of js, though; I learned that part in a community college course, and have a text book I can re-read between Google searches.) 

/dps

Reply all
Reply to author
Forward
0 new messages