Hi. I have a page.
The relevant elements are:
CSS of the object:
[code]
div.chColor
{
width: 60px;
height: 50px;
padding:0px;
border:2px solid;
border-color: rgb(84, 84, 84);
margin-left: auto;
margin-right: auto;
background-color: rgb(0,0,0);
text-align: center;
opacity: 1;
}
HTML code for the object:
[code]
<div class=”chColor” id=”colorthis”><br /></div>
Javascript code:
[code]colorTimer = window.setInterval(“colorme()”, 10);
red123 = “255”;
blue123 = “255”;
green123 = “255”;
colorstr = ‘rgb(‘+red123+’,’+blue123+’,’+green123+’);’;
document.write(colorstr);
function colorme() {
if (red123 < 255) {
red123 += 1;
} else {
morphTimer= false;
}
document.getElementById(“colorthis”).style.backgroundColor = “rgb(255,255,255);”;
}
function resetcolor() {
red123 = 0;
blue123 = 0;
green123 = 0;
}
Notice how the code has been reverted to a very simple state. The only code that is important anymore is the following.
[B] NOTE: Again, the above code has a lot of redundant stuff because I was trying to get something else working. It has, again, been reverted to a simple test state that still won’t work.
[code]“document.getElementById(“colorthis”).style.backgroundColor = “rgb(255,255,255);”;
.
It is called every ten milliseconds and it won’t work.
This is the code setup I am trying to get working.
[code]
colorTimer = window.setInterval(“colorme()”, 10);
red123 = “255”;
blue123 = “255”;
green123 = “255”;
colorstr = ‘rgb(‘+red123+’,’+blue123+’,’+green123+’);’;
function colorme() {
if (red123 < 255 && blue123 < 255 && green123 < 255) {
red123 += 1;
blue123 += 1;
green123 +=1;
} else {
morphTimer= false;
}
document.getElementById(“colorthis”).style.backgroundColor = colorstr;
}
function resetcolor() {
red123 = 0;
blue123 = 0;
green123 = 0;
}
This code is supposed to take a standard pitch black div and make it gradually turn right over time. This was my first attempt, which didn’t work. I eventually reverse engineered it to try to find the problem and found out that the line:
[code]document.getElementById(“colorthis”).style.backgroundColor = colorstr;
, a line reliable for changing every other aspect of the div in every other script, does not work. This is definitely the culprit.
However, it doesn’t always refuse to change.
If I use:
[code]document.getElementById(“colorthis”).style.backgroundColor = 255;
For some mysterious reason, the box turns blue.
I hope I am making sense. This is driving me nuts. On the same page with very similar codes, I’ve got divs morphing all other the place, divs on top of other divs, divs spinning around all over the page, but I cannot make one div do something as little as change a color.
It’s like going to a five star restaurant and being confused and angry as the waiter tells you “We serve all kinds of stuff unless it has bread on it or involves lettuce. We don’t believe in bread or lettuce.”