![]() |
error occurred in getting checkbox value - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: error occurred in getting checkbox value (/showthread.php?tid=71670) |
error occurred in getting checkbox value - kvanaraj - 09-11-2018 Code: <input type="checkbox" id="mycheck2" name="certid[]" Code: A PHP Error was encountered Code: controller RE: error occurred in getting checkbox value - Pertti - 09-11-2018 That looks like code from view file, not from controller, however because you are using name="certid[]", it's likely that you are looping over 0-6 indexes, where POST variable only sends values that were checked, so it might only have 1 value in certid array, if only one box was ticked. Check your POST data that comes in. RE: error occurred in getting checkbox value - kvanaraj - 09-11-2018 (09-11-2018, 10:53 PM)Pertti Wrote: That looks like code from view file, not from controller, however because you are using name="certid[]", it's likely that you are looping over 0-6 indexes, where POST variable only sends values that were checked, so it might only have 1 value in certid array, if only one box was ticked. controller file also attached. output Array ( [0] => 1_2 [1] => 2_2 [2] => 3_2 [3] => 4_2 [4] => 5_2 [5] => 6_ [6] => 7_ ) RE: error occurred in getting checkbox value - Pertti - 09-12-2018 First, when you use input name="array[]", you can't really trust indexes, if you select first and third item from one array, and second and fourth item from second array, you get: PHP Code: $array1[ So as fist thing, you ought to find a way to include related metadata (in your case, matching certid) somehow in the name/array that comes back. |