Changing Font in a Select Box

liunx

Guest
Does anyone know if you can change the text that shows up in a select box? Thanks.<!--content-->Yes, you can do that. I'm not exactly sure what you are looking for, but this demo will change the option that is selected's text to "New Text". If you are looking to add/remove options instead, that can be done as well.<br />
<br />
<html><br />
<head><br />
<br />
<script language="JavaScript" type="text/JavaScript"><br />
function changeText() {<br />
sel = document.myform.myselect;<br />
sel.options[sel.selectedIndex].text = "New Text";<br />
}<br />
</script><br />
<br />
</head><br />
<br />
<body><br />
<form name="myform"><br />
<select name="myselect"><br />
<option name="one">One</option><br />
<option name="two">Two</option><br />
<option name="three">Three</option><br />
</select><br />
<input type="button" value="Change" onclick="changeText();" /><br />
</form><br />
</body><br />
</html><!--content-->Changing the font is even easier... ;)<br />
<br />
<form name="myform"><br />
<select name="myselect" style="font-family:Verdana;"><br />
<option name="one">One</option><br />
<option name="two">Two</option><br />
<option name="three">Three</option><br />
</select><!--content-->Jona -<br />
<br />
Why the heck did you delete all your posts in this thread? My second post looks out of place now that you've deleted all yours... :confused:<!--content-->Originally posted by pyro <br />
My second post looks out of place now that you've deleted all yours... :confused: <br />
<br />
:D ... Better yours than mine. :D<br />
<br />
[Jona]<!--content-->You're kidding right? :rolleyes: I don't go around deleting all my posts if I don't know how to do something and someone show's me how... I'm just happy to have learned...<!--content-->Yeah, I'm kidding. I actually deleted them because there's really no point in having them there since you already answered him (in more ways than one), and I on the other hand misunderstood what he said altogether. Sorry, I just thought he said "font" not "text." :p<br />
But you're right, I was wrong. I didn't know you could edit the font of the SELECT element--I never tried it that way. I tried doing that with individual OPTIONs, and it didn't work--not in IE anyway..<br />
<br />
[Jona]<!--content-->Ok, whatever....<!--content-->Thanks guys, but for the record, I'm a 'SHE.' Thanks again!!<!--content-->Ah, sorry about that. My appologies.<!--content-->
 
Back
Top