我有一个代码,该部分将追加到表中,对于每个响应,我需要将序列号加1。我在控制台中得到的只是NaN
。
var qi = 1;
$.each(JSON.parse(resp), function(key, value) {
if (value.stock_type == "hardware") {
var s_type = 0;
} else {
var s_type = 1;
}
$("#emp-tbody")
.append('<tr role="row">' +
'<td><input type="checkbox" name="check" class="checkRow"></td>' +
'<td><input type="hidden" name="stock_type[]" value="' + s_type + '" disabled>' + value.stock_type + '</td>' +
'<td><input type="hidden" name="stock_type_value[]" value="' + value.master_stock_id + '" disabled>' + value.stock_name + '</td>' +
'<td><input type="hidden" name="stock_model_number[]" value="' + value.product_model_id + '" disabled>' + value.product_model_id + '</td>' +
'<td><input type="hidden" name="stock_model_serial_number_' + qi + '[]" value="' + value.product_serial_id + '" disabled>' + value.product_serial_id + '</td>' +
'<td><select class="form-control masterslist this_warranty" name="stock_warrenty[]" style="font-size: 15px;" disabled>' +
'<option></option>' +
'<option value="1">1</option>' +
'<option value="2">2</option>' +
'<option value="3">3</option>' +
'<option value="4">4</option>' +
'<option value="5">5</option>' +
'</select></td>' +
'<td><input type="hidden" name="product_quantity[]" value="' + value.qty_issue + '" disabled>' + value.qty_issue + '</td>' +
'</tr>');
var qi = qi + 1;
console.log(qi);
});