How to make all nasekomye and crazy checkboxes went back?

0 like 0 dislike
5 views
Create checkboxes dynamically, which is located near selectae. Ie selectors can be created dynamically, say, 10. Checkboxes should be the same. Select points come at the moment in the array (as their 10, then from key 0 to 9), and the checkboxes only come crazy and indexes are lost. I'd like to come, too, from 0 to 9, only wrote on-off, and it chooses those that are crazy, and comes to the server for example only 3 checkboxes (the ones that were crazy). Hidden field that is not very helpful, in js do not quite understand what to do
Help pliz
by | 5 views

2 Answers

0 like 0 dislike
Faced with such a feature, resolved through additional field hidden:

set_hidden_checkbox function(target, id) { var hidden = document.getElementById(id); if(hidden !== undefined) hidden.value = target.checked ? 'on' : 'off'; }

The value attribute in hidden needs to be initialized with a default value.
by
0 like 0 dislike
on the server are only transmitted crazy
you can explicitly specify an index name="check[4]"
or name="check_4"

And bekende for each select do if there exists an element in $_POST
for($n=0;$n<10;$n++){
if(!empty($_POST['check_'.$n])){ // array_key_exists($_POST['check'][$n])
by

Related questions

0 like 0 dislike
2 answers
asked May 1, 2019 by DeniSidorenko
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
33,932 users