javascript - How to handle multiple inputs of the same type in a html form? -
let's i've got form in can describe family:
<input type="text" name="mother"> <input type="text" name="father"> <input type="text" name="child">
but want people able add infinite number of children form. can use javascript continue adding new inputs more children, wonder how should name these. child1
, child2
, child3
, etc.? , on backend loop on children?
and if children need "age" input field. continue adding fields such child1_age
, child2_age
, child3_age
?
i guess work, have feeling there's smarter way of this. know of better way handle this? tips welcome!
html forms can use arrays input names. example:
<input type="text" name="child[]">
Comments
Post a Comment