So what I’m trying to do is something like this:
<html> <script language="javascript"> var i = 1; function changeIt() { my_div.innerHTML = my_div.innerHTML +"Titulo: <input type='text' name='mytext'+ i><br>" i++; } </script> <body <form name="form" action="post" method=""> Titulo: <input type="text" name="t" + i> HERE I WANT THE NAME TO BE SOMETHING + THE i VARIABLE IN JAVASCRIPT <input type="button" value="test" onClick="changeIt()"> <div id="my_div"></div> <br> <input type="submit"> </form> </body> </html>
I want to name the new dynamic textbox. So I could call it later on another PHP page.
Advertisement
Answer
You have to send the javascript value through ajax POST to the server and read the post via php.
Not so sure what your aim is but let me know if this helps.
<html> <script language="javascript"> var i = 1; function changeIt() { my_div.innerHTML = my_div.innerHTML + "Titulo: <input type='text' name='mytext'+ " + i + "><br>" i++; } </script> <body <form name="form" action="post" method=""> Titulo: <input type="text" name="t" + i> HERE I WANT THE NAME TO BE SOMETHING + THE i VARIABLE IN JAVASCRIPT <input type="button" value="test" onClick="changeIt()"> <div id="my_div"></div> <br> <input type="submit"> </form> </body> </html>