I want to beable to select an option in a select by the value that has been gotten from the session is this possible? So eg in my list:
- Book
- Conference
- Journal
开发者_如何学GoAnd for example book was in the session so it selects the book in the drop down menu.
Thanks in Advance Deani give following example with the help of ruby language. which select the 'Book' when session[:some] contains string 'Book'
<select>
<option value="Book" <%= 'selected' if session[:some]=="Book" %>>Book</option>
<option value="Conference" <%= 'selected' if session[:some]=="Conference" %>>Conference</option>
<option value="Journal" <%= 'selected' if session[:some]=="Journal" %>>Journal</option>
<select>
In pure HTML
<select name="">
<option value="Book" 'selected'>Book</option>
<option value="Conference" >Conference</option>
<option value="Journal" >Journal</option>
<select>
The HTML attribute selected
can be set for the option(s) you want selected.
As far as the session, you didn't describe how you are capturing that information - JavaScript, PHP, etc. If you specify this, you may get some sample code.
精彩评论