forms - PHP Dynamically added elements on Submit grab values -
solved
i found issue, while creating new row accidently grabbing tag , creating new form wrap every time added row.
so ended being:
form
row 1
form 2
row 2
form 3
row 3
form end
i trying submit form dynamically added fields keep getting initial one.
setup
htmldom form<br/> div->item<br/> --input<br/> --selectoption<br/> --textarea<br/> --radiobutton<br/> div->item(endwrap)
i have jquery grab initial wrap variable, once click add row elements +1 count.
i have tried following on form submit:
foreach ($_post['user'] $key=>$value ) { echo $key . " : " . $value; } <input id="user" type="text" name="user[]" autocomplete="off"/>
however shows me user of first item -> wrap or row.
my question best way iterate on dynamically added elements inside form on submission can add values db.
thank you! direction valid
tutorial appreciated (had no luck finding work).
match code following one:
<?php if(isset($_post['sub'])){ foreach ($_post['user'] $key=>$value ) { echo $key . " : " . $value."<br />"; } } ?> <html> <body> <form method='post'> val 1: <input id="user" type="text" name="user[]" autocomplete="off"/><br /> val 2: <input id="user" type="text" name="user[]" autocomplete="off"/><br /> val 3: <input id="user" type="text" name="user[]" autocomplete="off"/><br /> val 4: <input id="user" type="text" name="user[]" autocomplete="off"/> <input type="submit" name="sub"/> </form> </body> </html>
this working me. although, ids must not same fields taking same per case.
Comments
Post a Comment