webdev1
06-26-2003, 03:09 PM
Does anyone know if you can change the text that shows up in a select box? Thanks.
|
Click to See Complete Forum and Search --> : Changing Font in a Select Box webdev1 06-26-2003, 03:09 PM Does anyone know if you can change the text that shows up in a select box? Thanks. pyro 06-26-2003, 09:28 PM 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. <html> <head> <script language="JavaScript" type="text/JavaScript"> function changeText() { sel = document.myform.myselect; sel.options[sel.selectedIndex].text = "New Text"; } </script> </head> <body> <form name="myform"> <select name="myselect"> <option name="one">One</option> <option name="two">Two</option> <option name="three">Three</option> </select> <input type="button" value="Change" onclick="changeText();" /> </form> </body> </html> pyro 06-26-2003, 09:33 PM Changing the font is even easier... ;) <form name="myform"> <select name="myselect" style="font-family:Verdana;"> <option name="one">One</option> <option name="two">Two</option> <option name="three">Three</option> </select> pyro 06-26-2003, 09:50 PM Jona - 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: Jona 06-26-2003, 09:53 PM Originally posted by pyro My second post looks out of place now that you've deleted all yours... :confused: :D ... Better yours than mine. :D [Jona] pyro 06-26-2003, 09:55 PM 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... Jona 06-26-2003, 09:58 PM 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 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.. [Jona] pyro 06-26-2003, 10:01 PM Ok, whatever.... webdev1 06-27-2003, 06:38 AM Thanks guys, but for the record, I'm a 'SHE.' Thanks again!! pyro 06-27-2003, 07:09 AM Ah, sorry about that. My appologies. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |