I helped and provide code in another question that is almost exactly what you need. The question is at http:Q_23136553.html . Let me know how it helps or if you need help using it in your page.
bol
Main Topics
Browse All TopicsHi All,
I have a script that allows a user to click a button which generates a new row/table of form fields. This works fine only when I enter information in the first form field and click the add button it also copies the text in the form field as well. I need the new form fields to be initially blank. I have attached my code below.
Any help much appreciated.
Adam
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I helped and provide code in another question that is almost exactly what you need. The question is at http:Q_23136553.html . Let me know how it helps or if you need help using it in your page.
bol
Hi bol,
I have tried to adapt your code (as below) using the code for your previous posting solution. I do not need to add a counter to the address field. So instead of Address1, Address2 etc I just need Address[] so that it recognises it it an array. Unfortunately, when I output the array Address it has only remembered the last Address field I completed. Any suggestions?
Many thanks,
Adam
The main problem was not using the square brackets in the name's value for each field. That is what makes PHP able to get each field and create the array. The code below should now add the brackets and name to each field.
You do have to remove the ID attribute. It should be unique on a page and your method would cause duplicates. Since it isn't required usually you can leave it off. If you have to have an id then you will have to use a method that will keep it unique.
I also changed the onclick event. It doesn't need to start with javascript since it is an event and doesn't need the return.
Let me know if you have a question or how that works.
bol
Business Accounts
Answer for Membership
by: ZylochPosted on 2008-07-05 at 15:13:04ID: 21938567
You can use Javascript to manually reset all the fields, in lieu of a better solution. The correct action of cloneNode() is to copy the current form values.