title: Adding input element dynamically to form and storing the value in database
body: <p>I have to make a form which creates a button, clicking upon which a dynamic text field appears.</p>
  
  <p>My javascript for this is:</p>
  
  <pre><code>function add() {
  
      //Create an input type dynamically.
      var element = document.createElement("input");
      element.style.borderRadius ="5px";
      //Assign different attributes to the element.
      element.setAttribute("type", "text");
      element.setAttribute("value", "ip2");
      element.setAttribute("name", "ip2");
      element.setAttribute("placeholder", "ip2"); 
      element.setAttribute("required", "true");
      var foo = document.getElementById("fooBar");
  
      //Append the element in page (in span).
      foo.appendChild(element);
  
  }
  </code></pre>
  
  <p>and I am using following code for the button and required container:</p>
  
  <pre><code>&lt;form method="post" action="insert.php"&gt;
  &lt;INPUT type="button" value="Add" onclick="add(document.forms[0].element.value)"/&gt;
  
  &lt;span id="fooBar"&gt;&lt;/span&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Input field is fine. I only want to know how to take value from the dynamic input field and store it in the db.</p>
  
  <p>Thanks in advance</p>