niki
11-17-2005, 05:53 AM
I got this fabulous piece of code from an old forum thread. I just need to edit one thing and as I designer it is proving difficult. The code is based on all buttons using the same three css styles, however I have unique styles for each of my buttons (they are graphics). Like the lastID, I need to store the last class of the previously clicked button so I can refer to the class in function active(id,clas) so it would look something like
(LastID).className = LastClass:"")
instead off
(LastID).className = "butta":"")
Thank You :confused:
here is the original code
<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
<script language="JavaScript">
<!--
LastID = ""
function on(id,clas){
(LastID != id?document.getElementById(id).className = clas:"")
}
function off(id,clas){
(LastID != id?document.getElementById(id).className = clas:"")
}
function active(id,clas){
document.getElementById(id).className = clas; // onclick
if (LastID != id){
(LastID != ""?document.getElementById(LastID).className = "butta":"")
}
LastID = id
}
// -->
</script>
<style>
.butta{width:70;text-align:center;font-size:14;color:#000000;vertical-align:center;border-top:2px outset #eeeeee; border-left:2px outset #bbbbbb; border-right:2px outset #dddddd; border-bottom:2px outset #cccccc; background:#b0bbce}
.buttovera{width:70; text-align:center;font-size:14;vertical-align:center;color:#93a2bb;border-top:2px solid #93a2bb; border-left:2px solid #93a2bb; border-right:2px solid #93a2bb; border-bottom:2px solid #93a2bb;background:#b0bbce}
.buttdowna{width:70; text-align:center;font-size:12;vertical-align:center;color:#000000;border-top:2px inset #dce1e9; border-left:2px inset #dce1e9; border-right:2px inset #dce1e9; border-bottom:2px inset #dce1e9; background:#718099}
</style>
</HEAD><BODY>
<form>
<input type="button" value="button 1" id="button1" class="butta" onmouseover="on('button1','butta')" onMouseup="off('button1','buttovera')" onmousedown="active('button1','buttdowna')" onclick="this.blur()">
<input type="button" value="button 4" id="button2" class="butta" onmouseover="on('button2','butta')" onMouseOut="off('button2','butta')" onmousedown="active('button2','buttdowna')" onclick="this.blur()">
<input type="button" value="button 4" id="button3" class="butta" onmouseover="on('button3','butta')" onMouseOut="off('button3','butta')" onmousedown="active('button3','buttdowna')" onclick="this.blur()">
<input type="button" value="button 4" id="button4" class="butta" onmouseover="on('button4','butta')" onMouseOut="off('button4','butta')" onmousedown="active('button4','buttdowna')" onclick="this.blur()">
</form>
</BODY></HTML>
(LastID).className = LastClass:"")
instead off
(LastID).className = "butta":"")
Thank You :confused:
here is the original code
<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
<script language="JavaScript">
<!--
LastID = ""
function on(id,clas){
(LastID != id?document.getElementById(id).className = clas:"")
}
function off(id,clas){
(LastID != id?document.getElementById(id).className = clas:"")
}
function active(id,clas){
document.getElementById(id).className = clas; // onclick
if (LastID != id){
(LastID != ""?document.getElementById(LastID).className = "butta":"")
}
LastID = id
}
// -->
</script>
<style>
.butta{width:70;text-align:center;font-size:14;color:#000000;vertical-align:center;border-top:2px outset #eeeeee; border-left:2px outset #bbbbbb; border-right:2px outset #dddddd; border-bottom:2px outset #cccccc; background:#b0bbce}
.buttovera{width:70; text-align:center;font-size:14;vertical-align:center;color:#93a2bb;border-top:2px solid #93a2bb; border-left:2px solid #93a2bb; border-right:2px solid #93a2bb; border-bottom:2px solid #93a2bb;background:#b0bbce}
.buttdowna{width:70; text-align:center;font-size:12;vertical-align:center;color:#000000;border-top:2px inset #dce1e9; border-left:2px inset #dce1e9; border-right:2px inset #dce1e9; border-bottom:2px inset #dce1e9; background:#718099}
</style>
</HEAD><BODY>
<form>
<input type="button" value="button 1" id="button1" class="butta" onmouseover="on('button1','butta')" onMouseup="off('button1','buttovera')" onmousedown="active('button1','buttdowna')" onclick="this.blur()">
<input type="button" value="button 4" id="button2" class="butta" onmouseover="on('button2','butta')" onMouseOut="off('button2','butta')" onmousedown="active('button2','buttdowna')" onclick="this.blur()">
<input type="button" value="button 4" id="button3" class="butta" onmouseover="on('button3','butta')" onMouseOut="off('button3','butta')" onmousedown="active('button3','buttdowna')" onclick="this.blur()">
<input type="button" value="button 4" id="button4" class="butta" onmouseover="on('button4','butta')" onMouseOut="off('button4','butta')" onmousedown="active('button4','buttdowna')" onclick="this.blur()">
</form>
</BODY></HTML>