Forum Moderators: open

Message Too Old, No Replies

How to change <select> value defaults

<select> value defaults

         

keyplyr

5:31 pm on May 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




How do I designate a specific value to be displayed as default, other than the top (1) Thanks

<select name="name" size="1">
<option value="choice 1">1
<option value="choice 2">2
<option value="choice 3">3
<option value="choice 4">4
<option value="choice 5">5
<option value="choice 6">6
</select>

BlobFisk

5:34 pm on May 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can put selected on the option that you would like to be selected by default.

EG: <option value="choice1" selected>1

HTH

g1smd

10:49 pm on May 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Don't forget the closing </option> tag on each line.

keyplyr

1:47 am on May 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks

txbakers

3:43 am on May 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't forget the closing </option> tag on each line.

Technically the closing </option> tag is optional, but I always include it. I noticed that the Mac didn't render those tags correctly without the closing tag. IE on Windows did.

keyplyr

6:15 am on May 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




And I believe NN4x does not even display a dropdown without all closing tags.
(someone correct me if incorrect)

BlobFisk

8:50 am on May 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nope, you are quite correct keyplyr. NN4 won't show any part of the select list without all the </option> tags being in place.

Like txtbakers I always include them too - it just doesn't feel right to not close it!

g1smd

8:22 pm on May 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I didn't know that </option> was optional; thanks for the clarification, and the real world examples.

lorax

8:31 pm on May 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Technically the closing </option> tag is optional, but I always include it. I noticed that the Mac didn't render those tags correctly without the closing tag. IE on Windows did.

It isn't optional for XHTML. All tags need to be closed for XHTML [w3.org].