1
我写了一个代码来获取用户选择的值的详细信息。该代码工作正常,并显示数组。唯一的问题是显示错误的孩子节点。我在哪里做错了?迭代表中的多个行的值
function add_checkout_details(){
var total = $("#total").val();
var product_id = new Array();
var qty = new Array();
var price = new Array();
var amount = new Array();
var table = document.getElementById('myTable');
var rowCount = table.rows.length;
for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var txtBox0 = row.cells[0].innerHTML;
var txtBox1 = row.cells[2].childNodes[0].value;
var txtBox2 = row.cells[3].childNodes[0].value;
var txtBox3 = row.cells[4].childNodes[0].value;
var txtBox4 = row.cells[8].childNodes[0].value;
product_id.push(txtBox0);
qty.push(txtBox1);
price.push(txtBox2);
amount.push(txtBox3);
}
$.post('controller/add_checkout_details.php',{'product_id[]':product_id,'qty[]':qty,'price[]':price,'amount[]':amount,total:total}, function(data){
$('#error').text(data);
});
}
你可以添加你的表在代码中的样子吗? –