View Full Version : [HTML] Drop Down List - Selected?
Trigs
19-03-2009, 09:33 PM
Err how do I specify a select drop down field?
Ex:
<select size="1">
<option value="lol">lol</option>
<option value="ok">ok</option>
</select>
I tried some things but it didn't work.
MrCraig
19-03-2009, 09:37 PM
dont put size="1" in :P
Trigs
19-03-2009, 09:38 PM
My IDE automatically added that.
Iszak
19-03-2009, 11:46 PM
selected="selected"
e.g.
<select>
<option>One</option>
<option>Two</option>
<option selected="selected">Three</option>
</select>
Dentafrice
20-03-2009, 01:07 AM
selected="selected"
e.g.
<select>
<option>One</option>
<option>Two</option>
<option selected="selected">Three</option>
</select>
You don't need to put selected="selected", as selected is a bool value.
just:
<select name="country">
<option value="UK">United Kingdom</option>
<option value="CA">Canada</option>
<option selected value="US">United States</option>
</select>
Trigs
20-03-2009, 01:12 AM
Uh well can I do <select selected value="US"> instead? It's for an edit profile thing so I need to pull the country letters from the db.
Dentafrice
20-03-2009, 01:52 AM
No.. you do <option selected value="US">United States</option>
options go in selects.
Trigs
20-03-2009, 02:01 AM
So <option selected value="CA">United States</option> obviously wouldnt work right? So that basically means that theres no easy way to pull the country code from a database a show that option as selected right?
Dentafrice
20-03-2009, 02:05 AM
So <option selected value="CA">United States</option> obviously wouldnt work right? So that basically means that theres no easy way to pull the country code from a database a show that option as selected right?
Yeah there is, and yeah that would work.. why would you think it wouldn't work?
Trigs
20-03-2009, 02:08 AM
I don't know? lmao.
Iszak
20-03-2009, 02:25 AM
You don't need to put selected="selected", as selected is a bool value.
You use XHTML, you should know that just having
selected is invalid for all XHTML doctypes, and only valid in HTML 4.01, but
selected="selected" is valid in both - so hence my statement is correct.
Source
20-03-2009, 11:54 AM
I have to agree with iszak, I've found selected="selected" to have lesser issues when designing for multiple browsers and doc types.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2026 vBulletin Solutions Inc. All rights reserved.