title: How to send particular row id to a new table in database using ajax codeigniter?
body: <p>I have datatable that contains information like id, casename , productname and assign button.</p>
  
  <p>when i click on assign button bootstrap modal will pop-up for that particular  row id.</p>
  
  <p>In bootstrap modal i have dropdown option like lead1 and lead2.</p>
  
  <p>when i click on lead1 or lead2 that particular row id should be sent to the new table in the same database.</p>
  
  <p>view for boostrap modal:</p>
  
  <pre><code>&lt;!--Send Module start here--&gt;
  &lt;div id="assignModal" class="modal fade" tabindex="-1" role="dialog"&gt;
      &lt;div class="modal-dialog" role="document"&gt;
          &lt;div class="modal-content"&gt;
              &lt;div class="modal-header"&gt;
                  &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
                      &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
                  &lt;/button&gt;
                  &lt;h4 class="modal-title"&gt;Confirm Assign&lt;/h4&gt;
              &lt;/div&gt;
              &lt;div class="modal-body"&gt;
  
                  &lt;form action="#" id="Sendform" class="form-horizontal"&gt;
                  &lt;h4&gt;Please select to whom you want to send this case?&lt;/h4&gt; 
                     &lt;div class="form-group"&gt;
                          &lt;label class="control-label col-md-3"&gt;Assign To&lt;/label&gt;
                          &lt;div class="col-md-9"&gt;
                              &lt;select name="Assign To" class="form-control"&gt;
                                  &lt;option value=""&gt;--Select Leader--&lt;/option&gt;
                                 &lt;?php foreach($lists as $list) { ?&gt;  
    &lt;option value="&lt;?php echo $list['id'];?&gt;"&gt;Lead1&lt;/option&gt; 
    &lt;option value="&lt;?php echo $list['id'];?&gt;"&gt;Lead2&lt;/option&gt; 
  
    &lt;?php } ?&gt;
                              &lt;/select&gt;
                              &lt;span class="help-block"&gt;&lt;/span&gt;
                          &lt;/div&gt;
                       &lt;/div&gt;
                  &lt;/form&gt;
  
                  &lt;div class="modal-footer"&gt;
                      &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
                      &lt;button type="button" id="btnSend" onclick="send()" class="btn btn-danger"&gt;Send&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;&lt;!-- /.modal-content --&gt;
          &lt;/div&gt;&lt;!-- /.modal-dialog --&gt;
      &lt;/div&gt;&lt;!-- /.modal --&gt;
  </code></pre>
  
  <p>send function in view</p>
  
  <pre><code>function send()
  {
      $('#btnSend').text('saving...'); //change button text
      $('#btnSend').attr('disabled',true); //set button disable 
  
  
  
      // ajax adding data to database
      $.ajax({
          url : "&lt;?php echo site_url('tracking/ajax_send')?&gt;"+id,
          type: "POST",
          data: $('#Sendform').serialize(),
          dataType: "JSON",
          success: function(data)
          {
  
              if(data.status) //if success close modal and reload ajax table
              {
                  $('#assignModal').modal('hide');
                  reloadTable();
              }
              else
              {
                  for (var i = 0; i &lt; data.inputerror.length; i++) 
                  {
                      $('[name="'+data.inputerror[i]+'"]').parent().parent().addClass('has-error'); //select parent twice to select div form-group class and add has-error class
                      $('[name="'+data.inputerror[i]+'"]').next().text(data.error_string[i]); //select span help-block class set text error string
                  }
              }
              $('#btnSend').text('send'); //change button text
              $('#btnSend').attr('disabled',false); //set button enable 
  
  
          },
          error: function (jqXHR, textStatus, errorThrown)
          {
              alert('Error update data');
              $('#btnSend').text('send'); //change button text
              $('#btnSend').attr('disabled',false); //set button enable 
  
          }
      });
  }
  </code></pre>
  
  <p>note:- i dont know how to get value for id using foreach loop.</p>
  
  <p>when i choose  lead1 or lead2 in boostrap modal and click send button, that particular row id should be present in new table called case_assignment in same database.</p>
  
  <p>case_assignment  table contains column like id,lead_name,case_assigned_date.</p>
  
  <p>im new to programing and please help  me to proceed.</p>