我正在尝试编辑一个我从互联网上下载的开源项目 我想显示HSN的值。在表中,这是代码。
var $hsn;
$("#invoice_item").delegate(".product_name","change",function(){
var pid = $(this).val();
var tr = $(this).parent().parent();
if (pid != 0) {
$.ajax({
url : domain+"/includes/update.php",
method : "POST",
data : {get_price_qty:1,pid:pid},
success : function(data){
if(data == "NO_PRODUCT"){
alert("Sorry, Selected product is not available");
}else{
var ar = data.split(",");
tr.find(".pro_name").val(ar[2]);
tr.find(".price").val(ar[0]);
tr.find(".total_qty").val(ar[1]);
tr.find(".qty").val(0);
tr.find(".hsn").val(ar[3]);
tr.find(".amt").html(tr.find(".price").val() * tr.find(".qty").val());
$hsn=ar[3];
$("#discount").val(0);
}
}
})
}else{
alert("Please Select at least one product");
} })
现在添加新行的代码如下
if (isset($_POST["addNewRow"])) {
$num = $_POST["number"];
$pro = new DBOperation();
$rows = $pro->displayBrandAndCategory("products");
?>
<tr>
<td><b class="number"></b></td>
<td>
<select name="pname[]" class="form-control form-control-sm product_name">
<option value="0">Choose Product</option>
<?php
foreach ($rows as $row) {
?>
<option value="<?php echo $row['pro_id']; ?>"><?php echo $row["pro_name"]; ?></option>
<?php
}
?>
</select>
</td>
<td><input name="total_qty[]" type="text" class="form-control form-control-sm total_qty" readonly></td>
<td><input name="qty[]" type="text" class="form-control form-control-sm qty"></td>
<td><input name="hsn[]" type="text" class="form-control form-control-sm qty" readonly> </td>
<td><input name="price[]" type="text" class="form-control form-control-sm price" readonly></td>
<td>Rs.<span class="amt">0</span></td>
</tr>
<?php
exit();}
但是hsn列总是显示0,我试着这样做
document.write(ar[3]);
它正确显示HSN号码。我不确切知道下面的陈述是什么,有人可以向我解释一下吗?
tr.find(".hsn").val(ar[3]);