SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Nov 4, 2003, 04:05 #1
- Join Date
- Oct 2003
- Location
- Pakistan
- Posts
- 29
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
adding new text fields on button click..kindly help me
hi
the question is that i have some text fields on my form and on the click of a button"ADD NEW" i want to add a new text box in the same form but when i do this by simpley calling a function on button click and in that function i just wrote the code for a new text field but each time a new text field is placed but the previous contents of the form just dissapeare. so kindly guide me how to do this to append new fields on the same form on the clicking of a button
-
Nov 4, 2003, 15:26 #2
- Join Date
- Nov 2003
- Location
- São Paulo, Brazil
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Using the DOM:
Code:function addField(container) { var f=document.createElement("INPUT"); f.setAttribute("type", "text"); container.appendChild(f); } </script> .... <form onsubmit="return false;"> <input type="button" value="Add" onclick="addField(document.getElementById('cont'))"> </form> <div id="cont"></div>
Bookmarks