$this->input->post returning strage values for checkbox array - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: $this->input->post returning strage values for checkbox array (/showthread.php?tid=46959) |
$this->input->post returning strage values for checkbox array - El Forum - 11-21-2011 [eluser]Unknown[/eluser] Hi, I am using checkbox array in my form. When I post my form using ajax I get proper values in a array for check boxes selected values, but when I use native form submission using post method, I get strange values for the same check boxes in a array. Here is the code. HTML code in my view Code: <input type='checkbox' id="monday" name='lp_weekdays[]' value='1' <?= set_checkbox('lp_weekdays[]', '1') ?> required><label for="monday">Monday</label> Inside my controller Code: $this->form_validation->set_rules('lp_weekdays[]', 'Lesson Days', 'required|trim|xss_clean'); Code: $weekdays = $this->input->post('lp_weekdays'); Say I selected Monday, Wednesday and Friday. Using Ajax I get $weekdays = array(0 => 1, 1 => 3, 2 => 5) Using Native submit, I get $weekdays = array( 0 =>[1,2], 1 => [1,2], 2 => [1, 3, 5], 3 => [4,5] ) Any Idea why is it happening? Vibhu |