开发者

Incrementing input "name" value with JS

开发者 https://www.devze.com 2022-12-13 19:43 出处:网络
I have a table that is using jQuery to generate a \"new row\" when a button is clicked. When this new row is generated, new inputs are generated. Here is where I got the script from:

I have a table that is using jQuery to generate a "new row" when a button is clicked. When this new row is generated, new inputs are generated. Here is where I got the script from:

chris-barr[dot]com/projects/table_jquery

I am using this code on an order form for a client and I need to specifically target each "name" for the form processing part. The four that are static upon entering the开发者_JAVA技巧 page have "names" like this:

orderType1, orderType2, orderType3, orderType4

So, with each new row that is added, I need to append an incrementing name to each new input that is generated starting at orderType5 and maxing out at orderType10.

**I have max table rows set to 10.

here is my example:

http://www.tdidesign.com/designerorderform.php

I would appreciate any help or insight on how to get started with this. Thanks in advance.


I see you are already using an array on orderType[].

Is there a reason you don't want to simply turn this into a multidimensional array?

<input name="entry[orderType][]" />
<input name="entry[sampleNeeded][]" />
<input name="entry[yardage][]" />
<input name="entry[pattern][]" />
<input name="entry[manufacturer][]" />

Since your POST data will come out in order on the backend you will have everything in perfect ordering for parsing.

0

精彩评论

暂无评论...
验证码 换一张
取 消