Font Color

They have: 39 posts

Joined: Jun 2000

Is it possible to dynamically change the font color or backgroung-color e.g. field_name.style="color:red;"

Thanks!

They have: 184 posts

Joined: Jun 2000

I'm not quite sure what you're asking--care to elaborate?

They have: 39 posts

Joined: Jun 2000

I guess select box is a better example, is it possible to use different colors for different options dynamically

EmpID.options.length = 0;
for (var i = 0; i < Emp.getRowCount(); i++) {
NewOpt = new Option;

NewOpt.value = Emp.id[i];
NewOpt.text = Emp.employee_name[i];
if( Emp.id[i] == objects_array[r].object_id)
NewOpt.text.style="color:red;"
else
NewOpt.text.style="color:blue;"
EmpID.options[EmpID.options.length] =NewOpt;
}

They have: 184 posts

Joined: Jun 2000

Hmm.. You -could- try to specify different style attributes to each one.
Like..

They have: 39 posts

Joined: Jun 2000

Actually thats not possible because I am populating that list dynamically

They have: 231 posts

Joined: Feb 2000

Only in IE4+

document.body.style.backgroundColor = COLOR;

They have: 39 posts

Joined: Jun 2000

Thanks but I am not sure if its going to work for a select box

They have: 39 posts

Joined: Jun 2000

I am trying to change text color or background color for different options using javascript, please look at code above.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.