Dynamically create form fields (1 Viewer)

ddsunil

New member
Local time
Today, 16:58
Joined
Jun 21, 2002
Messages
6
Hello Everyone
I am working on a form and I am absolutely stumped on how to do this. Your help will greatly be appreciated.

This form will save data into a table with 6 columns. ANd the number of rows of data that will be saved will depend on the value selected in the drop down box.

As an example if the user enters 2, then the form should dynamically generate those 6 fields as two rows and some of the fields will be text boxes while some will be drop down boxes.

For now what I have done is created 12 sets of fields as I anticipate that a maximum of twelve rows of data will be entered in this screen. I have disabled all these fields and when the user enters 2 in the text box, I am enabling those two rows for the user to enter the data into.

Then comes the issue of saving. i am using an if condition to save. If the user selects 2, then I am writing the if condition and updating to the DB. THe problem that arises here is I have to write 12 if conditions and in the future if that 12 becomes 15, then the entire code should be rewritten to accomodate those new rows.

Is there anyway around it. Something like if a user selects 2, then the form is populated with txt1, txt2, txt3, cmb1, cmb2, cmb3 for the first row. ANd for the second row it should be txt4, txt5, txt6, cmd4, cmb5, cmb6.

And when saving use a do loop instead of writing so many if then else conditions?


I hope I am clear on what the issue is.

Thanks
Sunny
 

Users who are viewing this thread

Top Bottom