Change dropdown font color if value =

NEODARK

Gawd
Joined
Aug 10, 2004
Messages
1,002
Hey guys, need some help.

I'm having a bit of an issue which I can't figure out.

I have a few database driven drop down menus, which dynamically populate with True or False. I need to figure a way to dynamically change the font color depending on what the value of the field is.

Something like:

if dropdown value is True display in green font.
if dropdown value is False display in red font.

The script should be something like:

if theform.field.value = "True" then .......

Thanks for any suggestions you might have.
 
Code:
theform.field.style.color = 
    (theform.field.value == "True") ? 'green' : 'red';
of course, you could also add style="color: whatever;" when you create the tag initially with whatever server side language you're using, unless you're doing ajax stuff
 
Back
Top