清除后如何附加数据

I have to append data one by one by clicking button

$(document).ready(function() {
      var i = 0;
      $("#add_row").click(function() {
          $('#addr' + i).html("<td>" + (i + 1) + "</td><td><select id='myselect" + i + "' name='job_id[]" + i + "' class='form-control'><option value=''>Select the Job</option><?php 
              $mysql = "select * from ca_job where job_status != 'Closed' and job_customer_name = '".$com_id.
              "'"; $result1 = mysql_query($mysql) or die(mysql_error());
              while ($roww = mysql_fetch_array($result1)) {
                  $sql = "select * from `ca_job_type` where `jtype_id`= '".$roww['job_type'].
                  "'";
                  $res = mysql_query($sql) or die(mysql_error());
                  $row1 = mysql_fetch_array($res);
                  echo '<option value='.$roww['job_id'].
                  ' selected>'.$roww['job_id'].
                  '-'.$row1['job_type_name'].
                  '</option>';
              } ? > < /select></td > < td > < input name = 'invoice_description[]"+i+"'
              type = 'text'
              placeholder = 'invoice_description'
              class = 'form-control input-md'
              id = 'invoice_description' / > < /td><td><input name='sac_hsc_code[]"+i+"' type='text' placeholder='sac_hsc_code' class='form-control input-md'id='sac_hsc_code' / > < /td><td><select id='employee' name='tax_id[]"+i+"' class='form-control'><option value=''>Please select</option > <?php
            $sql = "select tax_id, tax_type, tax_comp, tax_Percent FROM ca_taxmaster where tax_comp = '0'";
            $resultset = mysql_query($sql) or die(mysql_error());
            while($rows = mysql_fetch_array($resultset)) { echo '<option value='.$rows['tax_id'].' selected>'.$rows['tax_type'].'</option>'; } ?> < /select></td > < td > < input name = 'amount[]"+i+"'
              type = 'text'
              placeholder = 'amount'
              class = 'form-control input-md' / > < /td>"
          );

Above source which I have posted was multiple input type up to that working but after selecting drop-down of id='myselect' for first list it was showing the values if press (+) button above value get cleared and showing last data alone but I need the values of first row and second row.

          $(document).ready(function() {
              $('#myselect' + i).change(function() {
                  var job_id = $(this).find(":selected").val();
                  var dataString = 'job_id=' + job_id;
                  $.ajax({
                      url: '<?=base_url(); ?>ajax/getjob.php',
                      dataType: "json",
                      data: dataString,
                      cache: false,
                      success: function(employeeData) {
                          $('.appendData').empty();
                          if (employeeData) {
                              $("#dvPassport").show();
                              $("#dvPassport1").hide();
                              var myselect = [employeeData];
                              employeeData.forEach(function(item) {
                                  var data = '<tr>';
                                  data += '<td>' + item.job_id + '</td>';
                                  data += '<td>' + item.disburse_Date + '</td>';
                                  data += '<td align="right">' + item.approved_amount + '</td>';
                                  data += '</tr>';
                                  $('.appendData').append(data);
                              });
                          } else {
                              $("#dvPassport").hide();
                              $("#dvPassport1").show();
                          } //else
                      }
                  });
              });
          });

          $('#tab_logic').append('<tr id="addr' + (i + 1) + '"></tr>');
          i++;
      });

      $("#delete_row").click(function() {
          if (i > 1) {
              $("#addr" + (i - 1)).html('');
              i--;
          }
      });

  });

Please click here to get clear view

In the above picture if I have selected dropdown two values showing and I am pressing the + button and selecting second drop-down first values getting cleared and showing second value what I have selected in the last dropdown. but I need the values of the first drop-down and second drop down.Please help me if anyone faces this problem .Thanks in advance.

i am not quit sure what you are trying to achieve but you forgot some ticks in for the value in the dropdowns, which might solve your problem

change

echo '<option value='.$roww['job_id'].' selected>'.$roww['job_id'].

to

echo '<option value="'.$roww['job_id'].'" selected>'.$roww['job_id'].

and

echo '<option value='.$rows['tax_id'].' selected>'.$rows['tax_type'].'</option>';

to

echo '<option value="'.$rows['tax_id'].'" selected>'.$rows['tax_type'].'</option>';

beside that

  1. you should really consider formating your code well, it is very hard to read and understand and therefore very hard to debug
  2. try to divorce your source, try to not mix php, html and javascript. it is possible to use it that way, but it also is a huge error source and very hard to maintain
  3. use the mysqli functions instead of mysql -> MySQL Improved Extension