mardi 21 février 2017

hidden inputs with same name: how to send only the values of selected checkboxes?

We have a number of checkboxes linked to several hidden fields with the SAME NAME. How could we send only the values of the selected checkboxes?

php

<input type"checkbox" name="<?echo $filename;?>_<?echo $variable;?>"
id="filename_<?echo $variable;?>" value="1">

<input type="hidden" name="item_<?echo $filename;?>" 
value="<?echo $quantity;?>">

If two or more checkboxes with the same name are selected, how can we then obtain the correct value for each hidden input rather than always the value of the last one?

our generated html

<input type"checkbox" name="idfilename_1"
<input type="hidden" name="item_idfilename" value="7">

<input type"checkbox" name="idfilename_2"
<input type="hidden" name="item_idfilename" value="5">

<input type"checkbox" name="idfilename_3"
<input type="hidden" name="item_idfilename" value="11">




Aucun commentaire:

Enregistrer un commentaire