freelance84 Posted July 21, 2010 Share Posted July 21, 2010 ($ii > 7) { echo "<option style=\"color:red;\">none choosen</option>"; } The above bit of code works perfectly; If $ii is greater than 7 the text color on that option is changed to red with a bit of CSS. The problem is, the said option is only red in the drop down list. When the user selects the option it reverts back to the default color, black. Is it possible to keep the option in red even after it has been choosen? Its no big deal either way, it's just it would look miles better if it could. Any pointers or advice would be very much appreciated. (I have a sneaky feeling it may not be CSS which will control this and it may be the dreaded js) Quote Link to comment https://forums.phpfreaks.com/topic/208406-colour-different-from-the-default/ Share on other sites More sharing options...
haku Posted July 21, 2010 Share Posted July 21, 2010 Please don't post PHP in the CSS section. Post the HTML output of your script. PHP is irrelevant to CSS. Quote Link to comment https://forums.phpfreaks.com/topic/208406-colour-different-from-the-default/#findComment-1089057 Share on other sites More sharing options...
freelance84 Posted July 21, 2010 Author Share Posted July 21, 2010 touch'e The output would be: <select name="name"> <option>oak</option> <option>maple</option> <option style="color:red;">none choosen</option> </select> Ok then, above is the output of the html. The drop down list has three options and the "none choosen" is styled red with CSS. When the said option is selected (ie when the drop down menu closes back up) its colour changes to the default, black. My question is, is it possible to keep its colour being red even after it has been selected? Quote Link to comment https://forums.phpfreaks.com/topic/208406-colour-different-from-the-default/#findComment-1089152 Share on other sites More sharing options...
DaiLaughing Posted July 22, 2010 Share Posted July 22, 2010 I wonder why I enjoy HTML/CSS sometimes! The text stays red in IE for me. In Opera it goes black at first but if I go to another tab or window and come back it goes red! Sorry I couldn't help. I tried using classes and a few other things but nothing. Quote Link to comment https://forums.phpfreaks.com/topic/208406-colour-different-from-the-default/#findComment-1089566 Share on other sites More sharing options...
DavidAM Posted July 22, 2010 Share Posted July 22, 2010 I read something about this the other day. It seems that when the combobox closes, the style of the SELECT element takes control rather than the style of the selected OPTION. At least, this happens in some browsers. The suggested solution was to use some javascript for the onClick attribute (I think) that would copy the style from the selected OPTION to the style of the SELECT element. I came across this when I was googling for a combobox color selector (or something like that). Quote Link to comment https://forums.phpfreaks.com/topic/208406-colour-different-from-the-default/#findComment-1089789 Share on other sites More sharing options...
freelance84 Posted July 30, 2010 Author Share Posted July 30, 2010 Yea i had a sneaky idea that it might be done with js Thanks for trying though. For the moment I will just hvae to stick with red in the drop down menu and black when selected. When I've completely finished the site with css html php and mysql, I will then start looking at implementing js for additional benifits. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/208406-colour-different-from-the-default/#findComment-1093059 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.