gagards200 Posted April 6, 2011 Share Posted April 6, 2011 The syntax below will give you 1 textbox and one button... In everytime I will click the button it will populate 1 textbox at a time... Now I need your help on how to get the content each of the textbox that has been populated.. Your urgent help is highly appreciated and GOD Bless Always..PHP FREAKS.. <html> <head> <title>Dynamic Form</title> <script language="javascript"> function changeIt() { var i = 1; my_div.innerHTML = my_div.innerHTML +"<br><input type='text' name='mytext'+ i>" } </script> </head> <body> <form name="form" action="post" method=""> <input type="text" name=t1> <input type="button" value="test" onClick="changeIt()"> <div id="my_div"></div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/232841-how-to-get-the-content-in-javascript-dynamic-textbox/ Share on other sites More sharing options...
RichardRotterdam Posted April 10, 2011 Share Posted April 10, 2011 You could use document.getElementsByTagName Here is an example read the comments to understand how it works: <script> window.onload = function() { // get input elements var inputElements = document.getElementsByTagName('input'); // loop through input elements for(var i = 0; i < inputElements.length; i++) { // output the value of each element use alert if you're not using firebug console.log(inputElements[i]['value']); } } </script> <input type="text" value="" name="txt1" /> <input type="text" value="not empty" name="txt2" /> <input type="text" value="" name="txt3" /> <input type="text" value="not empty either" name="txt4" /> Link to comment https://forums.phpfreaks.com/topic/232841-how-to-get-the-content-in-javascript-dynamic-textbox/#findComment-1199633 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.