0
I’m trying to pass values checkbox
in a array
, but the unchecked fields did not populate the array
. I need to fill in the unchecked fields with the value "N" for example:
Example in a loop of 5 results:
<?php
while(5x) : ?>
<td><input name="ocultarsub[]" type="checkbox" value="S" <?php if($ocultar_sub =='S'){echo "checked"; } ?> ></td>
<?php
endwhile;
?>
I get as output:
array(2) { [0]=> string(1) "S" [1]=> string(1) "S" }
I need to popular the unchecked with the letter N for example:
array(5) { [0]=> string(1) "S" [1]=> string(1) "S" [2]=> string(1) "N" [3]=> string(1) "N" [4]=> string(1) "N"}
Dude, an ugly way to do it, but that would solve it, would be to put an Hidden input for each checkbox and do a javascript function to change the value of Hidden when the respective checkbox was changed, then the form would send the hiddens
– JuniorNunes
easiest q this just pass a complete array only with the values and ids q vc selected for s and the rest remains the same
– Jasar Orion
The more unchecked values do not enter the array, the more key is lost the reference. The solution can under my nose, but today the sixth is affecting.
– denis
I managed to solve otherwise, I switched the checkbox by dropdown, so I get the amount denied. Thank you all for your help. You need to edit the title for closed or something?
– denis