If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Adding records to a form without submitting the form

In my form I take user details from the user, ie. name, address, etc. Now there are two options for user:
1. Submit form
2. Add records

If user dont have any previous addresses, he just submit's the form, which is working fine.

But if the user wants to add previous address details, he needs to click on "Add records" button. After clicking that button, user should be asked for number of records to be added and then according to the number entered, that many records must be added to the same form. After filling all the address details (present and previous) he must click on submit button to submit the form.

Can anyone tell me how to add the records in the form without submitting the form according to the number entered by the user.

See this thread for a very similar project. The following function (a modified version of the one from that thread) is the only thing you should copy; the functions called and the techniques used in the rest of that thread demonstrate a pattern for using this core function. (The cb in the parameter names stands for callback.)

It's actually supposed to be called when the document loads. For any simple arrangement, i.e. if you don't need to change the new elements at all before appending them to the document, only the first two arguments are required: the button to do the copying and the element to be copied. If you want to add a row to a table, pass the tr as the element. If the button is inside the same row, you might want to use the first callback parameter to remove it from the new rows.

To make a script run when the page loads, you can use either of these... (The first is preferable.)