How to loop through an array of inputs in a form?

后端 未结 3 431
被撕碎了的回忆
被撕碎了的回忆 2020-12-11 09:47

I am trying to look through some input fields in a form and add them to a database. The user sets the number of fields, so I can\'t do something like the code below because

3条回答
  •  难免孤独
    2020-12-11 10:23

    you can assign input names like he following(using javascript) and create a hidden field that contains the number of field, so when the user add more input fields, the hidden field is updated dynamically.

    
    
    
    
    

    so when you post this you know how many fields you have.

提交回复
热议问题