Welcome Guest, Not a member yet? Register   Sign In
form_dropdown allowing to select only one item
#1

[eluser]dinisptc[/eluser]
form_dropdown allowing to select only one item


Code:
<?php                                
              
                $js = 'id="contractorCompany"';
              
                echo form_dropdown('companyUID', $companies, set_value('companyUID', $companies),$js);
                                                
                ?>

we have to issues with the form dropdown

one : its showing opened like a list view
two: allows to select multiple items , but only one its selected maybe the last one

how to allow the selection of only one item
how to show the dropdown closed like a combo_box


thanks
#2

[eluser]Syllean[/eluser]
Quote:form_multiselect()

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[].
#3

[eluser]dinisptc[/eluser]

i am not interested in multiselect

how to allow the selection of only one item
how to show the dropdown closed like a combo_box
#4

[eluser]dinisptc[/eluser]

its using multiple in the html , how can i remove this

<select name="companyUID" id="contractorCompany" multiple="multiple">
<option value="">please select</option>
<option value="company_51b1a4fb87ea3">bcvbc</option>
<option value="company_51d55f5ac2344">sfsdf</option>
<option value="company_51d58175f248a">sfsdf</option>
<option value="company_51d5b4705989a">dddddddddddddd</option>
<option value="company_51d5bb11ddf12">firma do ze chagas</option>
<option value="company_51d5bb17df524">firma do ze chagas</option>
<option value="company_51d5bb27e2966">firma do ze chagas</option>
<option value="company_51d5bbb46e672">firma do ze</option>
<option value="company_51d5bbbf4dbed">firma do ze</option>
<option value="company_51d5bbcf17c30">firma do ze</option>
<option value="company_51d5bbd5721c6">firma do ze</option>
<option value="company_51d5bbdc13aab">firma do ze</option>
<option value="company_51d5bcdeebf32">firma do ze chagas</option>
</select>
#5

[eluser]Syllean[/eluser]
I misunderstood your question, I thought you wanted to be able to return multiple values.

Quote:You can also pass an array of multiple items through the third parameter, and CodeIgniter will create a multiple select for you.

Your problem is here:
Code:
set_value('companyUID', $companies)

The first parameter of set_value() is the field name, the second is your default value (selected) and you're passing an array so it makes a multiple select.

Quote:set_value()

Permits you to set the value of an input form or textarea. You must supply the field name via the first parameter of the function. The second (optional) parameter allows you to set a default value for the form. Example:

&lt;input type="text" name="quantity" value="&lt;?php echo set_value('quantity', '0'); ?&gt;" size="50" /&gt;
The above form will show "0" when loaded for the first time.





Theme © iAndrew 2016 - Forum software by © MyBB