title: How To Store Data of add more textbox in database using AJAX or PHP
body: <p>i have created one dynamic text box using Jquery/JavaScript. User can click on Add More Button JavaScript will add another input box in which user can enter some data.</p>
  
  <p>Problem :- JavaScript is working fine but I'm unable to get my head around how to store those data in data base. i need help on php or Ajax to pass these user data to database. Below are Parameter which i want to pass</p>
  
  <ol>
  <li>Hotel ID</li>
  <li>Cancellation ID</li>
  <li>(Dynamic Userdata)++1</li>
  </ol>
  
  <p>Below Are mention my Codes. </p>
  
  <p>JavaScript :-</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
          $(document).ready(function() {
              $('#btnAdd').click(function() {
                  var num     = $('.clonedInput').length; 
                  var newNum  = new Number(num + 1);     
                  var newElem = $('#input' + num).clone().attr('id', 'input' + newNum);
                  &lt;!--  newElem.children(':first').attr('id', 'from' + newNum).attr('name', 'from' + newNum); --&gt;
                  $('#from1').attr('id', 'from' + newNum).attr('name', 'from' + newNum);
                  $('#to1').attr('id', 'to' + newNum).attr('name', 'to' + newNum);
                  $('#rate1').attr('id', 'rate' + newNum).attr('name', 'rate' + newNum);
                  $('#input' + num).after(newElem);
                  $('#btnDel').attr('disabled','');
              });
              $('#btnDel').click(function() {
                  var num = $('.clonedInput').length; 
                  $('#input' + num).remove();    
                  $('#btnAdd').attr('disabled','');
                  if (num-1 == 1)
                      $('#btnDel').attr('disabled','disabled');
              });
              $('#btnDel').attr('disabled','disabled');
          });
          $(document).ready(function() {
              $('#sub').click(function() {
  
              var from1=$("#from1").val();
              var to1=$("#to1").val();
              var rate1=$("#rate1").val();
              var from2=$("#from2").val();
              var to2=$("#to2").val();
              var rate2=$("#rate2").val();
  
               var num = $('.clonedInput').length; //number of times clicked
  
              $( "p" ).html( "&lt;b&gt;Single:&lt;/b&gt; " + from1+ to1+rate1+ from2+ to2+rate2);
              $( "p" ).html("number"+num);
  
              })
              });
      &lt;/script&gt;
  </code></pre>
  
  <p>HTML CODE :-</p>
  
  <pre><code>&lt;form id="myForm"&gt;
      &lt;tr id="input1" style="margin-bottom:4px;" class="clonedInput"&gt;
          &lt;td&gt; &lt;input type="text" name="hotel_id" id="1" /&gt;&lt;/td&gt;
          &lt;td&gt; &lt;input type="text" name="from1" id="from1" /&gt;&lt;/td&gt;
          &lt;td&gt; &lt;input type="text" name="to1" id="to1" /&gt;&lt;/td&gt;
          &lt;td&gt; &lt;input type="text" name="rate1" id="rate1" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="button" id="btnDel" value="remove name" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;div&gt;
      &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
         &lt;td&gt; &lt;input type="button" id="btnAdd" value="add another name" /&gt;&amp;nbsp;&lt;input type="button" id="sub" value="submit" /&gt;&lt;/td&gt;
  
      &lt;/tr&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Please help me with this...</p>