Welcome Guest, Not a member yet? Register   Sign In
Help with multiple select boxes
#6

[eluser]CarNinja[/eluser]
[quote author="dobbler" date="1220533060"]Hi CarNinja,

This didn't make any sense to me either. The form fields should look like this:

<INPUT type="CHECKBOX" name="itemtype[]" value="1" /><br />
<INPUT type="CHECKBOX" name="itemtype[]" value="2" /><br />
<INPUT type="CHECKBOX" name="itemtype[]" value="3" /><br />

Then try print_r($_POST); and you should get an array of the values.. They have to be checked though.

The name of the input being an array threw me, I came from an ASP background so this was confusing but it worked so I'm not asking any questions!

Hope this helps, it was driving me mental so I feel your pain..

Rob.[/quote]

Thanks Rob,

I actually found the solution a few moments ago. I'll post it here for future reference:

When adding the field to the page, it needs the brackets, as you've pointed out.

Code:
<?= form_dropdown( 'ad_states[]', $states, $this->input->post( 'ad_states' ), 'id="ad_states" multiple="multiple" tabindex="8"' )?>


However, when you access the variable, you drop the brackets:

Code:
$this->input->post( 'ad_states' )


I hope this clears anything up for people searching in the future. Smile


Messages In This Thread
Help with multiple select boxes - by El Forum - 08-24-2008, 05:03 PM
Help with multiple select boxes - by El Forum - 08-24-2008, 08:01 PM
Help with multiple select boxes - by El Forum - 08-24-2008, 08:07 PM
Help with multiple select boxes - by El Forum - 09-04-2008, 12:46 AM
Help with multiple select boxes - by El Forum - 09-04-2008, 01:57 AM
Help with multiple select boxes - by El Forum - 09-04-2008, 02:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB