Dear Mr.Massimo, Thanks for your reply. I tried the following way to get what I wanted to be done: I took a SQLFORM and ran a for loop and inserted extra extra fields in it. The _name attribute of those fields was like 'nm'+str(count) where count was the looping variable. But when I tried accessing its using form.vars.('nm'+str(count)) then it gives me invalid format error. So how can we access form elements generated at runtime?
With Regards, Rahul Priyadarsi. On 12 June 2012 08:11, Massimo Di Pierro <massimo.dipie...@gmail.com> wrote: > This is best done in JS clientside. something like: > > jQuery(function(){ > jQuery('#table_field__row').hide(); > > > jQuery('#table_otherfield').change(function(){if(jQuery('#table_otherfield').checked()) > jQuery('#table_field__row').show();}); > }); > > > On Monday, 11 June 2012 01:08:44 UTC-5, rahulserver wrote: >> >> Is there a way to create a form from controller(or view) in web2py to >> have variable number of fields depending on query? >> To be more specific,I have following table in my model: >> >> db.define_table('Commitments',**Field('Account',requires=IS_**IN_DB(db, >> db.Account_Master.id, '%(Account)s %(State)s')),Field('TID',db.** >> Transaction_Master),Field('**Entry_Date','date',default=** >> request.now),Field('pending','**boolean',default=True),Field('** >> Due_Date','date'),Field('Mode'**,requires=IS_IN_SET(('DD','** >> Direct_Banking','Cash','Other'**)),default='Other'),Field('** >> Amount','integer',default=0),**Field('Remark')) >> >> The client wants to select a particular account and find all its entries >> in a form wherein he may check or uncheck the value of field 'pending' and >> accordingly the value of this field gets updated. So this needs a form with >> variable number of rows. I do not want to use sqlform.grid for this and I >> would prefer to have the code in the controller. >> >