groovicus, on Mar 1 2010, 06:00 AM, said:
Try something like this:
object.style.backgroundColor="#00FF00". Don't forget the semi-colon at the end, or javascript will put it where it thinks it should go, which can sometimes cause bad problems.
CSS does not map directly to java script:
http://www.w3schools.com/Css/pr_background-color.asp
Hello again,
I've got it sort of working with the following code -
<script type="text/javascript">
function changecolor(txt) {
ColorValue= document.getElementById(txt).style.backgroundColor;
if (ColorValue = '#0000FF')
{
document.getElementById(txt).style.backgroundColor = '#FF0000';
return;
}
if (ColorValue = '#FF0000' )
{
document.getElementById(txt).style.backgroundColor = '#00FF00';
return;
}
if (ColorValue = '#00FF00')
{
document.getElementById(txt).style.backgroundColor = '#00CCFF';
return;
}
return;
}
</script>
<div class="titlebar" id="titlebar" onclick="changecolor('titlebar');" style="position:absolute; left:200px; top:20px; margin: 0px; border: solid; height:30px; width:540px"><center>February Page View Counts</center></div>
However, it will only change color once to the red in the first if block. If I take the return; statements out of the ifs, it falls all the way through, changing color at each step, and settling on the last color in the last if statement.
I tried to do several "else if" clauses but they would not trigger at all. I don't know what was wrong there as I was copying, and pasting the code for the else ifs directly from W3 Schools examples.
Why won't the function work again after the first time I click the div???
Thanks, Ray Parrish