在php

时间:2017-11-09 08:16:50

标签: php jquery twitter-bootstrap forms codeigniter

在这里,我有一个动态表格形式,用户可以在其中添加或删除多行。

喜欢这样:

enter image description here

现在每当我用数据填充两行或更多行时,它只通过POST方法传输第一行的单个(第一)数据。

现在,每当我填写如下数据时。

enter image description here

它给了我这个:

Array ( 
    [clientName] => Hello 
    [clientAddress] => 93638524 
        [itemName] => Array([0] => Enduramass) 
        [price]      => Array([0] => 1500) 
        [gst]        => Array([0] => 4) 
        [quantity] => Array([0] => 1) 
        [total]      => Array([0] => 1500) 
    [subTotal]   => 21500.00 
    [totalGstAmount] => 1060.00
    [totalAftertax] => 22560 
)

这是我的html表单

<tr>
    <td><input class="case" type="checkbox"/></td>
    <td><input type="text" data-type="productCode" name="itemName[]" id="itemName_1" class="form-control autocomplete_txt" autocomplete="off"></td>
    <td><input type="text" data-type="productName" name="price[]" id="price_1" class="form-control autocomplete_txt" autocomplete="off" readonly></td>
    <td><input type="text" name="gst[]" id="gst_1" class="form-control totalLineGST" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" readonly></td>
    <td><input type="number" name="quantity[]" id="quantity_1" class="form-control changesNo" min="1" max="5" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
    <td><input type="text" name="total[]" id="total_1" class="form-control totalLinePrice" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" readonly><input type="text" id="eachgstAmount_1" class="form-control totalEachGST" ></td>
</tr>

这是我的jQuery多个追加行代码

var i=$('table tr').length;
$(".addmore").on('click',function(){
    html = '<tr>';
    html += '<td><input class="case" type="checkbox"/></td>';
    html += '<td><input type="text" data-type="productCode" name="itemName[]" id="itemName_'+i+'" class="form-control autocomplete_txt" autocomplete="off"></td>';
    html += '<td><input type="text" data-type="productName" name="price[]" id="price_'+i+'" class="form-control autocomplete_txt" autocomplete="off" readonly></td>';
    html += '<td><input type="text" name="gst[]" id="gst_'+i+'" class="form-control totalLineGST" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" readonly></td>';
    html += '<td><input type="number" name="quantity[]" min="1" max="5" id="quantity_'+i+'" class="form-control changesNo" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>';
    html += '<td><input type="text" name="total[]" id="total_'+i+'" class="form-control totalLinePrice" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" readonly>';
    html += '<input type="text" id="eachgstAmount_'+i+'" class="form-control totalEachGST" >';
    html += '</td></tr>';
    $('table').append(html);
    i++;
});

请指导我,我哪里出错?

0 个答案:

没有答案