【发布时间】:2015-06-28 19:30:25
【问题描述】:
我有一个现有的 html 表单,它使用数组来存储多个行值。所以我没有不同行的同一字段的特定名称。在 PHP 页面中,我根据索引匹配行。 在下面的表格中,如何使按钮+和-来增加和减少特定行数量的值?
第 1 行
<input type="text" name="product[]" />
<input type="text" name="price[]" value="" onChange="updatePrice()" />
<input type="text" name="quantity[]" value="" onChange="updatePrice()" />
<input type="button" onclick="inc(this)" value="+"/>
<input type="button" onclick="dec(this)" value="-"/>`
第 2 行
<input type="text" name="product[]" />
<input type="text" name="price[]" value="" onChange="updatePrice()" />
<input type="text" name="quantity[]" value="" onChange="updatePrice()" />
<input type="button" onclick="inc(this)" value="+"/>
<input type="button" onclick="dec(this)" value="-"/>
第 3 行
<input type="text" name="product[]" />
<input type="text" name="price[]" value="" onChange="updatePrice()" />
<input type="text" name="quantity[]" value="" onChange="updatePrice()" />
<input type="button" onclick="inc(this)" value="+"/>
<input type="button" onclick="dec(this)" value="-"/>
【问题讨论】:
标签: javascript php jquery html button