function addRow() {
	$("#addRowBtn").button("loading");

	var tableLength = $("#productTable tbody tr").length;

	var tableRow;
	var arrayNumber;
	var count;

	if(tableLength > 0) {		
		tableRow = $("#productTable tbody tr:last").attr('id');
		arrayNumber = $("#productTable tbody tr:last").attr('class');
		count = tableRow.substring(3);	
		count = Number(count) + 1;
		arrayNumber = Number(arrayNumber) + 1;					
	} else {
		// no table row
		count = 1;
		arrayNumber = 0;
	}

	$.ajax({
		url: 'php_action/fetchExp.php',
		type: 'post',
		dataType: 'json',
		success:function(response) {
			$("#addRowBtn").button("reset");			

			var tr = '<tr id="row'+count+'" class="'+arrayNumber+'">'+	

               '<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					''+count+''+
					'</div>'+
				'</td>'+	

               '<td>'+
					'<div class="form-group">'+

					'<select class="form-control" name="standardexp_id[]" id="standardexp_id'+count+'" required>'+
						'<option value="">~~SELECT~~</option>';
						// console.log(response);
						$.each(response, function(index, value) {
							tr += '<option value="'+value[0]+'">'+value[1]+'</option>';							
						});
													
					tr += '</select>'+
					'</div>'+
				'</td>'+				
				
				
				
				'<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="number" name="amount[]" id="amount'+count+'" autocomplete="off" class="form-control" placeholder="Amount"  min="1" required/>'+
					'</div>'+
				'</td>'+
				
				'<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					
					'<select class="form-control" name="chargeable_to[]" id="chargeable_to'+count+'">'+
						'<option value="">~~SELECT~~</option>';
						// console.log(response);
						//$.each(response, function(index, value) {
							tr += '<option value="YES">YES</option>';	
                            tr += '<option value="NO">NO</option>';								
						//});
													
					tr +='</select>'+
					
					
					//'<input type="text" name="chargeable_to[]" id="chargeable_to'+count+'" autocomplete="off" placeholder="Paid by" class="form-control" min="1"/>'+
					
					
					'</div>'+
				'</td>'+
				
				'<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					'<input type="text" name="invoice[]" id="invoice'+count+'" autocomplete="off" placeholder="Invoice No" class="form-control" required/>'+
					'</div>'+
				'</td>'+
				
				
				'<td style="padding-left:20px;">'+
					'<div class="form-group">'+
					
					'<select class="form-control" name="debitNote[]" id="debitNote'+count+'">'+
						'<option value="">~~SELECT~~</option>';
						// console.log(response);
						//$.each(response, function(index, value) {
							tr += '<option value="TSH">TSH</option>';	
                            tr += '<option value="USD">USD</option>';								
						//});
													
					tr +='</select>'+
					
					
					//'<input type="text" name="debitNote[]" id="debitNote'+count+'" autocomplete="off" placeholder="Debit Note"  class="form-control"/>'+
					'</div>'+
				'</td>'+
				
				
				
				'<td>'+
					'<button class="btn btn-default removeProductRowBtn" type="button" onclick="removeProductRow('+count+')"><i class="glyphicon glyphicon-trash"></i></button>'+
				'</td>'+
			'</tr>';
			if(tableLength > 0) {							
				$("#productTable tbody tr:last").after(tr);
			} else {				
				$("#productTable tbody").append(tr);
			}		

		} // /success
	});	// get the product data

} // /add row

function removeProductRow(row = null) {
	if(row) {
		$("#row"+row).remove();


		subAmount();
	} else {
		alert('error! Refresh the page again');
	}
}


function removeProductRow1(row = null) {
	if(row1) {
		$("#row1"+row).remove();


		subAmount();
	} else {
		alert('error! Refresh the page again');
	}
}










