CodeIgniter Forums
need help with checkbox - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: need help with checkbox (/showthread.php?tid=34659)



need help with checkbox - El Forum - 10-06-2010

[eluser]webstudent_101[/eluser]
well i have this in my view..

<?= form_open('merchant/result')?>
<? foreach($employees as $item):?>
&lt;?= form_checkbox('employee', $item->user_firstname)." - ".$item->user_firstname; ?&gt;<br/>
&lt;? endforeach;?&gt;
&lt;?= form_submit('submit', 'enter')?&gt;
&lt;?= form_close();?&gt;

and in the 'merchant/result' i wanted to get all the checked employee.. but every time i check all the last employee will be the only one to show.. is there a way to make the checked items an array or something? ive been searching the internet for quiet some time about codeigniter and multiple checked items with no possible aid ti my problem..

thanks alot.. and tnx in advance


need help with checkbox - El Forum - 10-06-2010

[eluser]Fireclave[/eluser]
you can use form_checkbox('employee[]'...)
so you have an array !
employee[] <- Array


need help with checkbox - El Forum - 10-06-2010

[eluser]webstudent_101[/eluser]
tnx alot.. ill try it right now.. XD


need help with checkbox - El Forum - 10-06-2010

[eluser]Fireclave[/eluser]
Here an example
http://www.plus2net.com/php_tutorial/array_checkbox.php

you are welcome


need help with checkbox - El Forum - 10-06-2010

[eluser]webstudent_101[/eluser]
yep works perfectly.. i changed it to multiselect() which made it much easier.. hehe.. jst added some line of codes in my form_helper for the dropdown function..