Results 1 to 2 of 2
Thread: Creating a Form
Oct 25, 2012, 20:08 #1
- Join Date
- Jun 2010
- 0 Post(s)
- 0 Thread(s)
Creating a Form
When I click on an "Add" button, it would create a new form with the "First Name", "Last Name" field and 2 textboxes, just like the original.
So if I click on the "Add" button 5 times, it would create 5 new forms for me. Same idea applies for the "Delete" button.
Here's my code:
<!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>JS Bin</title> </head> <body> <FORM NAME="myForm" id="facebookAcc" onsubmit="return false"> First Name: <input type="text" name="1stName" ><br /> Last Name: <input type="text" name="lastName" ><br /><br /> <input id="bu_add" type="button" value="Add" > <input id="bu_delete" type="button" value="Delete"> </FORM> </body> </html>
If you can help me out, I would greatly appreciated. Or if you know what this is call, I can just look it up.
Oct 25, 2012, 21:08 #2
- Join Date
- Jan 2007
- Christchurch, New Zealand
- 83 Post(s)
- 4 Thread(s)
- Are you wanting to create the new form fields a from ones already existing in the form (via templating) or are you wanting to use scripting to create the fields separately?
- If the former, have you considered how to layout the form fields so that the script can easily find the fields that it needs to template from?
- If the latter, what happens when changes need to occur to the form fields or their layout? It's not as easy to change those things when scripting is used to generated those fields
- How are the new fields going to be named so that the server can tell the difference between them? Are they going to be numbered sequentially, or used as an array.
- Are the add and delete buttons going to be at the bottom of the form? If so, what is the delete button going to delete?
- If you have a separate delete button on each field, what happens when you delete a row in the middle? If the fields are sequentially numbered will there be a missing gap, or will you renumber the names of the different fields?
- When you add a field, does it look at each potential row number for a suitable gap in the sequence, or does it just add one to the row at the end?
- If the former, does the new row go in to place at the appropriate part of the sequence, or does it get added on to the end of the form?
- If the latter, will the server know how to deal with things when there are missing numbers from the sequence?
I suggest that you template from an existing row using paragraphs to separate each row, and use an array notation on the field names if you intend for PHP to be the server-side solution for receiving your form submission.