Welcome Guest, Not a member yet? Register   Sign In
Using select box in form help
#1

[eluser]oldrock[/eluser]
Hi,

since i m new to code igniter now i m hardly doing some coding with forms.., so if i use form_select it gives error as call to undefined function .

the task i want to do is select some data from the database and i need to populate in the option of the select field..


thanks in advance
#2

[eluser]mi6crazyheart[/eluser]
form_select!!! I afraid , that there is any such form helper function available in CI. May be, i'm wrong but i only got a function "form_multiselect()" in Form helper user manual...

User manual: http://ellislab.com/codeigniter/user-gui...elper.html
#3

[eluser]oldrock[/eluser]
Hi Thanks for your reply..,

could you please share a piece of example using form_multiselect so that it would be great helpful for me..

Thanks in advance
#4

[eluser]mi6crazyheart[/eluser]
"form_multiselect" is same like "form_dropdown()". Here is an example of "form_dropdown". You can use "form_multiselect" in the same way as it...

Code:
$options = array(
                  'small'  => 'Small Shirt',
                  'med'    => 'Medium Shirt',
                  'large'   => 'Large Shirt',
                  'xlarge' => 'Extra Large Shirt',
                );

$shirts_on_sale = array('small', 'large');

echo form_dropdown('shirts', $options, 'large');

// Would produce:

<select name="shirts">
<option value="small">Small Shirt</option>
<option value="med">Medium Shirt</option>
<option value="large" selected="selected">Large Shirt</option>
<option value="xlarge">Extra Large Shirt</option>
</select>

echo form_dropdown('shirts', $options, $shirts_on_sale);

// Would produce:

<select name="shirts" multiple="multiple">
<option value="small" selected="selected">Small Shirt</option>
<option value="med">Medium Shirt</option>
<option value="large" selected="selected">Large Shirt</option>
<option value="xlarge">Extra Large Shirt</option>
</select>

For more info must go through: http://ellislab.com/codeigniter/user-gui...elper.html
#5

[eluser]oldrock[/eluser]
Thanks that helped me well

i have fetched value from th database and populated it in the select box

with the following code

&lt;?php
echo form_dropdown('team',$teams);

?&gt;

<select name="team">
<optgroup label="0">
<option value="team" selected="selected">Australia</option>
</optgroup>
<optgroup label="1">
<option value="team" selected="selected">Bangladesh</option>
</select>

the thing i want to set the value of option field as below dynamically

<option value="Bangladesh">Bangladesh</option>

help me to do that with the form_dropdown. it would be grate full to me

thanks in advance




Theme © iAndrew 2016 - Forum software by © MyBB