View Full Version : Preselected option in <select>

10-25-2007, 12:10 AM
Hello Everyone,

I know that I can have the code:

<select name=test>
<option value="1">test1</option>
<option value="2" selected>test2</option>
<option value="3">test3</option>

However, is it possible to have the selected option in the <select> tag?

This Does Not Work
<select name=test selected="a2">
<option value="1">test1</option>
<option value="2">test2</option>
<option value="3">test3</option>


10-25-2007, 12:53 AM
No that causes invalid markup.

10-26-2007, 03:58 AM
Well, you could do this with JavaScript (see this site (http://www.mredkj.com/tutorials/tutorial003.html)).

But why do you want to adjust the selected option in the "select" tag? What's wrong with just using the "selected" attribute in the "option" tag?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum