Welcome Guest, Not a member yet? Register   Sign In
What is the easiest way of reselecting the selected value
#1

[eluser]Neeraj Kumar[/eluser]
Hi all!

I have been working with form validation helper.

I want to know that what would be the easiest way of re selecting the selected value posted via form submission.

Adding a check to every <option> is not a good idea, especially for big lists.

Code:
<select name="test" id="course_type">
    <option value="1" &lt;?php (set_value('test') == '1')? 'selected': '' ; ?&gt;>first</option>
    <option value="2" &lt;?php (set_value('test') == '2')? 'selected': '' ; ?&gt;>Second</option>
    <option value="3" &lt;?php (set_value('test') == '3')? 'selected': '' ; ?&gt;>Third</option>
</select>
#2

[eluser]pistolPete[/eluser]
Have a look at the user guide: http://ellislab.com/codeigniter/user-gui...elper.html
Quote:set_select()

If you use a <select> menu, this function permits you to display the menu item that was selected. The first parameter must contain the name of the select menu, the second parameter must contain the value of each item, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE).
#3

[eluser]Neeraj Kumar[/eluser]
thanks for pointing out, I mis understood the procedure.. Smile




Theme © iAndrew 2016 - Forum software by © MyBB