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

back ground color not changing

Status
Not open for further replies.

Blobishthing

Programmer
Feb 16, 2002
23
0
0
AU
I have this script where it gets a random number and from that if it is less than 56 the bgColor is green if it is more than 56 the bgColor is black but it is always black
here is the script...

<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
<!--
now = new Date()
num = now.getSeconds() + now.getMinutes() + now.getHours()

if(num <= 56)
{
document.bgColor=&quot;green&quot;;
}
if(num > 57)
{
document.bgColor=&quot;black&quot;;
}
if(document.bgColor=&quot;black&quot;)
{
document.fgColor=&quot;white&quot;;
}
document.write(num);
//-->
</script>
 
Your statement:
if(document.bgColor=&quot;black&quot;)
sets the bgColor to black
you have to use == to evaluate 2 values like so:
if(document.bgColor==&quot;black&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top