samedi 21 mars 2015

Pass selected form input to backend

Consider a simple HTML form like



<form>

<div>
<input type='checkbox' name='selections[]' value='1' />
<input type='text' name="inputs[]" value='' />
</div>

<div>
<input type='checkbox' name='selections[]' value='2' />
<input type='text' name="inputs[]" value='' />
</div>

<div>
<input type='checkbox' name='selections[]' value='3' />
<input type='text' name="inputs[]" value='' />
</div>

</form>


There are three rows, assume only the 2nd, 3rd rows are checked, and all three text inputs are filled with (a, b, c), so in my backend (PHP), I can have two arrays


e.g.



$selections = array(2, 3);
$inputs = array('a', 'b', 'c');


What is the easy way to remove a from the $inputs since the checkbox is not checked? i.e. So I can loop the two arrays more easily.


Aucun commentaire:

Enregistrer un commentaire