title: How To Pass Dynamically Added Table Rows Form Values to Javascript Using Post to Send Database
body: <p>I am using Laravel.</p>
  
  <p>I have dynamic rows and each row has own form with individual values.</p>
  
  <p>I am trying to pass each row form with values when submit the button to Javascript.
  To retrieve data in Server.I don't want to refresh page because I am using Modal.</p>
  
  <p>Here is my Code</p>
  
  <pre><code>&lt;table id="selectedWagesTable" class="display" cellspacing="0" width="100%"&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Worker&lt;/th&gt;
          &lt;th&gt;Balance&lt;/th&gt;
          &lt;th&gt;Confirm&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
  @foreach($items as $item)
  
     &lt;tr&gt;
          &lt;td class="standartTable2"&gt;
              &lt;?php echo $item['worker_id'] ?&gt;
          &lt;/td&gt; 
  
          &lt;td class="standartTable2"&gt;
              £ &lt;?php echo $item['balance'] ?&gt;
          &lt;/td&gt;
  
          &lt;td class="standartTable2"&gt;
  
  {{ Form::open(['id'=&gt;item['workerId'],'name' =&gt; item['workerId']]) }}
                  {{ Form::hidden('workerId', $item['workerId'],['id' =&gt; $item['workerId'])}}
                  {{ Form::hidden('balance', $item['balance'],['id' =&gt; $item['balance']])}}
                  {{ Form::submit('Click To Confirm', 
                                      array(
                                          'class'=&gt;'btn btn-sm btn-success',
                                          'id'=&gt;'submitButton',
                                          'oncontextmenu'=&gt;'return false',
                                          )) }}
  {{ Form::close() }}
  
          &lt;/td&gt;
      &lt;/tr&gt;
      @endforeach
  
  
  &lt;/tbody&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Script</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function(){
  
      $("#submitButton").click(function(e){
          e.preventDefault();
          $.get('hpoAccounts',function(data){
              console.log(data);
          });
      });
  
      $("#submitButton").click(function(e) {
          e.preventDefault();
  
          var workerId = $('#workerId').val();
          var balance = $('#balance').val();
  
          $.post('hpoAccounts',{
              workerId:workerId,
              balance:balance
          },
  
              function(response,status){
              console.log(response);
          });
      });
  });
  </code></pre>
  
  <p></p>