Welcome Guest, Not a member yet? Register   Sign In
Checkboxes and this->input->post troubles
#1

[eluser]jtotheb[/eluser]
I would like to submit a form that has some checkboxes that have been ticked.

When i click submit i go to another controller / model that tries to pick up the values from that form and do something with them.

Trouble is, when i try and access the results from this->input->post it only gives me one of the check boxes that were ticked.

I have all the checkboxes with the same name but different values in the form. I presume this is allowed and should allow me to grab the values from post by specifying the name as the index key and looping through however many there are?

I seem to be asking a lot of questions today. Perhaps my brain is tired.

Again, any help very gratefully received!
#2

[eluser]LuckyFella73[/eluser]
hej,

as far as I know checkboxes need to be named uniqe!
Maybe you mixed checkboxes with radio buttons?
You can group radio buttons by giving them the same
name to force the user to select only one of the options.

correct me if I'm wrong,

Luckyfella
#3

[eluser]座頭市[/eluser]
Are the checkbox names in array form, i.e.
Code:
/* Will interpret input as an array */
<?=input_checkbox('foo[]', 'bar1');?>
<?=input_checkbox('foo[]', 'bar2');?>
<?=input_checkbox('foo[]', 'bar3');?>

/* Will interpret input as single value */
<?=input_checkbox('foo', 'bar1');?>
<?=input_checkbox('foo', 'bar2');?>
<?=input_checkbox('foo', 'bar3');?>
#4

[eluser]jtotheb[/eluser]
座頭市 - You are right, however when i tried doing that foo[] it did not work when i tried to get the array values out.

Thing is, for some reason that now seems to be working.

I wonder what i was doing last night!

i feel a bit sheepish now, amazing what a good nights sleep will do for you!




Theme © iAndrew 2016 - Forum software by © MyBB