mercredi 1 août 2018

getting checkbox values created dynamically

I have a table form whose rows are generated dynamically. Each row has two input elements and a checkbox.

<tr>
    <td><input type="text" name="names[]" class="form-control" required="required"></td>
    <td><input type="number" name="rates[]" class="form-control" required="required"></td>
    <td><input class="simple" type="checkbox" name='disallow_flag[]' value='1'/><input type="hidden" name="disallow_flag[]" value="1"></td>
    <td></td>
</tr>

On adding more rows dynamically and checking few boxes, I get following output:

Array ( 
[names] => Array 
( [0] => fadsf [1] => sdfaf [2] => asdffd ) 
[rates] => Array 
( [0] => 12 [1] => 22 [2] => 11 ) 
[disallow_flag] => Array 
( [0] => 1 ) [submit] => submit )

I have even added a input element of hidden type with the same name. Is there any other way how I can identify for which items a checkbox is checked so that I can insert field values accordingly?




Aucun commentaire:

Enregistrer un commentaire