text: $(document).ready(function(){
  $("#id").click(function(){
  	var id=$("#id").val();
  	$.ajax({
  		url:"p.php",
  		data:"id="+id,
  		success:function(value){
  			var data = value.split(",");
  			$("#barang").val(data[0]);
  			$("#harga").val(data[1]);
  			
  			
  		
  			
  			}
  		
  		
  		});
  	
  	});
  	});
  	function sum() {
        var txtFirstNumberValue = document.getElementById('harga').value;
        var txtSecondNumberValue = document.getElementById('banyak').value;
        var result = parseInt(txtFirstNumberValue) * parseInt(txtSecondNumberValue);
        if (!isNaN(result)) {
           document.getElementById('jumlah').value = result;
        }
  }
  
  
  
  
  // Add button Delete in row
  $('tbody tr')
      .find('td')
      //.append('<input type="button" value="Delete" class="del"/>')
      .parent() //traversing to 'tr' Element
      .append('<td><a href="#" class="delrow">Delete Row</a></td>');
  
  // For select all checkbox in table
  $('#checkedAll').click(function (e) {
  	//e.preventDefault();
      $(this).closest('#tblAddRow').find('td input:checkbox').prop('checked', this.checked);
  });
  
  // Add row the table
  $('#btnAddRow').on('click', function() {
      var lastRow = $('#tblAddRow tbody tr:last').html();
      //alert(lastRow);
      $('#tblAddRow tbody').append('<tr>' + lastRow + '</tr>');
      $('#tblAddRow tbody tr:last input').val('');
  });
  
  // Delete last row in the table
  $('#btnDelLastRow').on('click', function() {
      var lenRow = $('#tblAddRow tbody tr').length;
      //alert(lenRow);
      if (lenRow == 1 || lenRow <= 1) {
          alert("Can't remove all row!");
      } else {
          $('#tblAddRow tbody tr:last').remove();
      }
  });
  
  // Delete row on click in the table
  $('#tblAddRow').on('click', 'tr a', function(e) {
      var lenRow = $('#tblAddRow tbody tr').length;
      e.preventDefault();
      if (lenRow == 1 || lenRow <= 1) {
          alert("Can't remove all row!");
      } else {
          $(this).parents('tr').remove();
      }
  });
  
  // Delete selected checkbox in the table
  $('#btnDelCheckRow').click(function() {
  	var lenRow		= $('#tblAddRow tbody tr').length;
      var lenChecked	= $("#tblAddRow input[type='checkbox']:checked").length;
      var row	= $("#tblAddRow tbody input[type='checkbox']:checked").parent().parent();
      //alert(lenRow + ' - ' + lenChecked);
      if (lenRow == 1 || lenRow <= 1 || lenChecked >= lenRow) {
          alert("Can't remove all row!");
      } else {
          row.remove();
      }
  });
  