Dynamic textfields in javascript and get values through $_POST in php -


I have a JavaScript code, as explained below, I need to solve my problems.
I have a data base in which I store the questions in a table and then store my options in another table, to store that ID as a reply in the question table, I am right from the question options table. Need an answer ID

  var template = ''; Var calculation = 1; Function addTextField () {template + = "& lt; input type = 'text' id = 'option_" + count + "' name = 'name1 []' & gt;"; Template + = "& lt; input type = 'radio' id = 'option_" + count + "' name = 'answer')); Document.getElementById ("content1"). InnerHTML = Template; Count ++; } Function getId () {var radio = document.getElementsByName ('answer'); (Var i = 0, length = radios.length; i & lt; length; i ++) {if (radios [i] checked) (// checked radio var id = radio [i ] With whatever you want. ; Document.write (id); // var name = document.getElementsById ('id'); //document.write(name); // Only one radio can be checked logically, do not check the rest; }}}  

This is my php code:

  foreach ($ as name $ value) Include {mysqli_query ($ conn, "Ask a Question (option, Question_ID) values ​​('$ value', '$ qid');}  

I selected the ID of the radio text field How do I get it?

I have to store text field value on a table and then the ID of that row another table.

I think use the $ _ POST array Your problem may be solved.

Check this answer:


Comments