开发者

Select option in drop down menu HTML

开发者 https://www.devze.com 2023-01-05 08:36 出处:网络
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:

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

Dean


i 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消