how to create a multi select box with out selected options codeigniter
You should use the form_multiselect() helper.
$options = array( 'small' => 'Small Shirt', 'med' => 'Medium Shirt', 'large' => 'Large Shirt', 'xlarge' => 'Extra Large Shirt', );echo form_multiselect('shirts', $options);
The only thing that comes to my mind is using an array with more than one empty element:
$options = array( 'small' => 'Small Shirt', 'med' => 'Medium Shirt', 'large' => 'Large Shirt', 'xlarge' => 'Extra Large Shirt', );$array = array('','');echo form_dropdown('shirts',$options, $array);
This code works, though not the most elegant out there.
UPDATE:
This is even better, didn't remember it at first!
echo form_multiselect('shirts',$options,'','');
Output:
<select name="shirts" multiple="multiple"><option value="small">Small Shirt</option><option value="med">Medium Shirt</option><option value="large">Large Shirt</option><option value="xlarge">Extra Large Shirt</option></select>
i tried every solution but no one works with me i tried ( form_dropdown from from helper) i also tried ordinary way with multiple= "multiple"
is it common problem with codeigniter ??
Updatethe error was that anyone forget to name in html attribute as array cars[]
<select **name="cars[]"** multiple="multiple"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel">Opel</option> <option value="audi">Audi</option></select>
this works fine always .