Welcome Guest, Not a member yet? Register   Sign In
set_select on select elements that are arrays...
#1

[eluser]drakeonfire[/eluser]
Hello,

I'm currently trying to create a table that allows you to add a new row using jQuery .. though that's all working etc. But I'm naming my select boxes like so:
example[]

The issue is, this works fine for input boxes, but when I try to see if they selected a certain value, it doesn't work, if i leave it like this:
Code:
echo '<option value="'.$item-&gt;id.'" '.set_select('ing_ingredient[]', $item->id).'>'.$item->name.'</option>';
It will basically make ALL the select boxes have the same value...

and if I try and use an actual index like so:
Code:
echo '<option value="'.$item-&gt;id.'" '.set_select('ing_ingredient[2]', $item->id).'>'.$item->name.'</option>';
Then it just makes them all the default option (even if the ing_ingredient[2] does contain something)...

This is rather annoying, as I need to make it so they can have as many select boxes as they want, but it wont remember what they select on form submission :/

Any ideas? Thank you.




Theme © iAndrew 2016 - Forum software by © MyBB