Hi All,
I have a series of buttons that I want to be on/off style buttons - i.e. click once to turn on and once to turn off. In order to show that any given button is on, the button text will turn white, and when off it will turn brown.
I have all this working, except that if a user does not move the mouse off of the button and wants to turn the button on and off, the color stops changing after the first on/off. Wondering if anyone can shed any light on why this is. The relevant javascript is as follows:
and a link to the example website I'm working on is here (it is the 5 buttons at the top that are causing me grief):
http://www.oldboymusic.com/testsite"][/URL]
Any help is massively appreciated.
Cheers,
skinicod.
I have a series of buttons that I want to be on/off style buttons - i.e. click once to turn on and once to turn off. In order to show that any given button is on, the button text will turn white, and when off it will turn brown.
I have all this working, except that if a user does not move the mouse off of the button and wants to turn the button on and off, the color stops changing after the first on/off. Wondering if anyone can shed any light on why this is. The relevant javascript is as follows:
Code:
var mySelectedTop = 'None';
var lightCol = '#E6E4DE';
var darkCol = '#2E0E03';
function changeTopColor(buttonID, newColor){
if(mySelectedTop != buttonID){
myDiv=document.getElementById(buttonID);
myDiv.style.color = newColor;
}
}
function topSelect(buttonID){
if(buttonID == mySelectedTop){
mySelectedTop = 'None';
changeTopColor(buttonID,darkCol);
}
else{
currentSelected = mySelectedTop;
mySelectedTop = buttonID;
changeTopColor(currentSelected,darkCol);
changeTopColor(mySelectedTop,lightCol)
}
}
and a link to the example website I'm working on is here (it is the 5 buttons at the top that are causing me grief):
http://www.oldboymusic.com/testsite"][/URL]
Any help is massively appreciated.
Cheers,
skinicod.