Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A question

Status
Not open for further replies.

elise28

Programmer
Mar 2, 2003
12
SG
Hi,
I would like to ask if it is possible to let the values in the combo box to appear italic?

<select onChange=&quot;selectEntity(this.form)&quot; name=&quot;entity&quot;>
<option value selected><cfoutput>#view.entity#
</cfoutput></option>
<option>Pls Select</option>
</select>

As above, i wish to make the
cfoutput>#view.entity#</cfoutput> to appear italic.
 
You can change the text style of ALL VALUES within the SELECT tag with a style sheet but I don't think you can set one Option in italic and other ones non-italic.
By the way, to set all your seect content in italic :
Code:
<select onChange=&quot;selectEntity(this.form)&quot; name=&quot;entity&quot; style= &quot;FONT-STYLE: italic;&quot;>
Water is not bad as long as it stays out human body ;-)
 
In theory you should be able to change the properties of individual options using CSS thus:

Code:
<select name=&quot;test&quot;>
<option>Normal</option>
<option style=&quot;font-style: italic;&quot;>Italic</option>
<option style=&quot;font-weight: bold;&quot;>Bold</option>
<option style=&quot;color: red;&quot;>Red</option>
<option style=&quot;background-color: red;&quot;>Red 2</option>
</select>

However browsers may, and do, ignore one or more of these directives. On IE6 the foreground and background colour changes work, the bold and italic don't (presumably because colour changes don't affect the size of the text presented). Perhaps you could use colour coding to highlight your entry? (though this, too, may not work on other browsers).

Incidentally, before someone picks me up on this, if you go with this solution, don't use the
Code:
style
attribute as I've done above, but define a class for highlighted <option>s in a stylesheet and use the
Code:
class
attribute to point to it. It'll make life easier if you decide to change it later. Also remember that a significant proportion of the population is red/green colourblind. -- Chris Hunt
Extra Connections Ltd
 
Thank you Targo & ChristHunt..
As i would like to make the cfoutput>#view.entity#</cfoutput> to appear italic only.so as to differentiate it from other values. Because when retrieve from the database, this cfoutput>#view.entity#</cfoutput> will always appear when user re-select aother entity. It's alright if can't be done. Thks anyway.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top