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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass CSS value from Javascript to change element color

Status
Not open for further replies.

saira78

Technical User
Jan 14, 2003
40
0
0
CA
How would I do the following?

In the js, upon connection to this web-based/telnet/oracle application, a value is stored for the environment the user is logged into - i.e. prod, test, train, stage, inst, etc.

I want to change the font colour or the background image to indicate further which environment the user is logged into. This resides in the CSS. How would I do that?

Here is the JS that grabs this value and stores:

else if(key == "app.menu.title")
{
var title = HTMLEncode(replace(val, "\\", "/"));
var envStr = new String (window.defaultStatus);
envStr = envStr.substring(31,(envStr.length-6));
document.all.divProgName.innerHTML = '[' + envStr + '] ' + title;

...

And here is where I want the CSS to change depending on the value of envStr:

.bProgramName
{
BACKGROUND: url(../images/programname_bg.gif);
BORDER-BOTTOM: solid 1px #336;
BORDER-TOP: solid 1px #336;
COLOR: #336;
FONT: bold .8em/2 "Georgia", Trebuchet MS, Arial, Helvetica, sans-serif;
LETTER-SPACING: 1px;
PADDING: 0 0 2px 20px
}

Any help is greatly appreciated. Hope this message makes sense.

Thanks,
Saira

 
Is it a style declaration within the page (if so you can loop through the document.styleSheets collection and change any values you like) or an external stylesheet (in which case you can't touch it and would have to loop through all the elements in the document checking the class assigned and overwriting the background style)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top