Dynamically adding rows to an input form.

Results 1 to 2 of 2

Thread: Dynamically adding rows to an input form.

  1. #1
    Join Date
    Dec 1969

    Default Dynamically adding rows to an input form.

    Can anyone help with the following:<BR>I have a form that captures info about a project. Three items in my form can either have only one set of values or can have multiple different values. Instead of posting the form, looping back and posting another row I want to be able to add rows to the form one at a time. ie: If one project only has one set of values the default form is sufficient, another project needs 3 sets of values so the first set would be added, an add row button pushed and there would be another row of text boxes under the original ones for more values. As many row as was required could then be added.<BR><BR>How do I do this? <BR>1) Increasing the form size, textbox id&#039;s etc...<BR>2) The SQL statement for processing this data...<BR><BR>Anyone have a solution, seen any good articles ...<BR><BR>Thanks

  2. #2
    Join Date
    Dec 1969

    Default Yeah...

    Personally I really despise forms like this. They cause me alot of headaches. And I think the extra post really isnt that big of a deal. It allows users to enter one thing at a time and review what they did.. if a user has to fill out 5 things at once and hit submit lots of mistakes can occur.. So lots more code needs to be written to check for that. But my projects require me to make them on certain sites ( well.. the client.. and boss.. its a conspiracy they dont listen to me )<BR><BR>The approach that I use when I create a form like this is <BR><BR>obviously pass the number of rows you want on the querystring then use that to display the rows. On each row put a number after the form field name.. or something that you can use to uniquely identify the form value. The Loop iterator is what I use..<BR><BR>For iterator = 1 to numofrows<BR> &#060;input type="text" name="somename&#060;%=iterator%&#062;"&#062;<BR>ne xt<BR><BR>Then when submitting you can do something like this...<BR><BR>Maxrows = "10" &#039; Just a precaution.. dont want a crash to happen<BR><BR>Iterator = 1<BR><BR>&#039; This verify&#039;s that the field is there and should be processed<BR>&#039; Note isEmpty checks to see if the field is there.. if the field has a value of "" it will still be true<BR><BR>While not isEmpty(request.form("somefield" & iterator)) AND Iterator &#060;= Maxrows<BR><BR> &#039; Enter your data here <BR> SQL = "INSERT INTO SOMETABLE (somefield) VALUES (&#039;" & request.form("somefield" & iterator) & "&#039;)"<BR>Wend<BR><BR><BR>Ive had forms where I needed to update multiple values as well.. This is slightly different and can be done different ways. The approach I use is to have an hidden input tag with the primary key value and just name it with the iterator as before. Then just use the primary key to update it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts