如何映射动态数组的输入字段 [英] How to map dynamic array of input fields
本文介绍了如何映射动态数组的输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有一组输入字段的表单:
I have a form with a set of input fields:
<form>
<div class="row">
<input type="text" name="product[1]">
<input type="text" name="qty[1]">
</div>
</form>
我还使用jquery的clone()函数动态地向DOM添加新行。
I also add new rows dynamically to the DOM with jquery's clone() function.
增加索引号码的最佳方法是什么?或者在提交PHP脚本之前,是否有更好的映射产品和数量字段的方法?
What is the best way to increase the index number? Or is there a better way to 'map' the product and qty fields before submitting to a PHP script?
推荐答案
<form>
<div class="row">
<input type="text" name="product[]">
<input type="text" name="qty[]">
</div>
<div class="row">
<input type="text" name="product[]">
<input type="text" name="qty[]">
</div>
</form>
这篇关于如何映射动态数组的输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文