Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create form fields using Javascript

Status
Not open for further replies.

kate8

Programmer
Feb 14, 2001
184
US
Hi everyone,

I need to create some form fields by using Javascript.
It should work like this: when people click the buttom "Add a new record", a form field will be created with last name, first name, address and such.. People can fill in the form and submit. I need allow the people click as much as they want.

I use onClick
<input type="button" value="Click to Add a new record" onclick="createForm()">

but in createdForm(), should I use
document.createElement or
document.write or something else?

How can I let people keep adding the new form fields?

Thank you for any help!!


 
What are you planning on doing with the form data? What will be the "action" on the form?

 
I'd say you should use 'document.createElement', as using 'document.write' after the page has loaded will completely overwrite the current page contents.

You should also investigate '<node>.appendChild'

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top