Welcome Guest, Not a member yet? Register   Sign In
multi_select - limit the number of options shown...
#1

[eluser]Unknown[/eluser]
Hi

I just started using CI this morning and really like it in comparison to Cake/Zend and some other frameworks I've been working with...it just seems to be more intuitive to me...anyway, I am porting one of my sites over to see how easy it will be (or hard : D) and I have a form select that allows multiple selections, when I plugged the array into form_multiselect() in my view it displayed all the options (24)...I just want to limit it to 4-5 and have the user scroll to see the rest...

the docs didn't indicate how to do that:

Lets you create a standard multiselect field. The first parameter will contain the name of the field, the second parameter will contain an associative array of options, and the third parameter will contain the value or values you wish to be selected. The parameter usage is identical to using form_dropdown() above, except of course that the name of the field will need to use POST array syntax, e.g. foo[].


Can someone post the code for that? Thanks.
#2

[eluser]geitvdplas[/eluser]
$options = array();
$attr = ' id="shirts" size="5" ';

echo form_dropdown('shirts', $options, 'large', $attr);
#3

[eluser]Unknown[/eluser]
Thanks alot...

..oops...something ain't working right...

Here's my code:

Code:
$designerlist = array();

foreach($designers->result() as $row):
  $designerlist[$row->workername] = $row->workername;
endforeach;
                            
$attr = "size='5'";
                            
echo form_multiselect('designers', $designerlist, $attr);

It doesn't seem to be adding the size attribute...

Here's my source code:

Code:
<select name="designers"  multiple="multiple">
<option value="Amy">Amy</option>
<option value="Jen">Jen</option>
<option value="Ed">Ed</option>
<option value="MarkS">MarkS</option>
<option value="Nicholas">Nicholas</option>
<option value="Coleman">Coleman</option>
<option value="David">David</option>

<option value="Mark">Mark</option>
<option value="Todd">Todd</option>
<option value="Tomek">Tomek</option>
<option value="Randy">Randy</option>
<option value="Steve">Steve</option>
<option value="JenMcG">JenMcG</option>
<option value="Aaron">Aaron</option>
<option value="Rosanne">Rosanne</option>
<option value="Bill">Bill</option>

<option value="Dana">Dana</option>
</select>
#4

[eluser]pickupman[/eluser]
Welcome to the boards and CI!
$attr will be your 4th argument, the 3rd is your selected value.




Theme © iAndrew 2016 - Forum software by © MyBB