robrichardson
Programmer
Hi
I've got a set of buttons which have a SwapImageRestore happening on the onMouseOut, a simple rollover however what I want to happen is that when the button is clicked a function is called which swaps all the buttons, this I have working but after the function the onmouseout event is disabled until different button is clicked.
I tried dynamically setting the onMouseOut value of the button within the first function which changes the images however it seems not to change. Heres the code
The function which runs when the button is clicked:
function ResetButton(btno){
var imgno;
var x;
for(x=1;x<11;x++){
imgno="Image" + x;
if (btno==x)
{
document.images
.src='../images/asBar_0' + x + '-over.gif';
document.images
.onMouseOut='MM_SwapImgRestore(0)';
}
if (x!=btno)
{
document.images
.src= "../images/asBar_0" + x + ".gif";
document.images
.onMouseOut='MM_SwapImgRestore(1)';
}
}
}
function MM_swapImgRestore(decide) {
if(decide==1){ //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}
}
The buttons *NOTE: I've only been testing with a couple of buttons so far ie. Image1, Image2
<tr>
<td width="120" height="16"><a href="asArch.asp" target="mainFrame" onMouseOut="MM_swapImgRestore(1)" onClick="ResetButton(1)" onMouseOver="MM_swapImage('Image1','','../images/asBar_01-over.gif',1)" ><img src="../images/asBar_01.gif" name="Image1" width="120" height="27" border="0" id="Image1"></a></td>
<td width="120" height="16"><a href="asQuanSurv.asp" onMouseOut="MM_swapImgRestore(1)" onClick="ResetButton(2)" onMouseOver="MM_swapImage('Image2','','../images/asBar_02-over.gif',1)" target="mainFrame"><img src="../images/asBar_02.gif" name="Image2" width="120" height="27" border="0" id="Image2"></a></td>
<td width="120" height="16"><a href="asBsEng.asp" onMouseOut="MM_swapImgRestore(1)" onMouseOver="MM_swapImage('Image3','','../images/asBar_03-over.gif',1)" target="mainFrame"><img src="../images/asBar_03.gif" name="Image3" width="120" height="27" border="0" id="Image3"></a></td>
<td width="116" height="16"><a href="asCivil.asp" onMouseOut="MM_swapImgRestore(1)" onMouseOver="MM_swapImage('Image4','','../images/asBar_04-over.gif',1)" target="mainFrame"><img src="../images/asBar_04.gif" name="Image4" width="120" height="27" border="0" id="Image4"></a></td>
<td width="124" height="16"><a href="asQualCont.asp" onMouseOut="MM_swapImgRestore(1)" onMouseOver="MM_swapImage('Image5','','../images/asBar_05-over.gif',1)" target="mainFrame"><img src="../images/asBar_05.gif" name="Image5" width="119" height="27" border="0" id="Image5"></a></td>
</tr>
<tr>
<td height="16"><a href="asIntDesign.asp" target="mainFrame" onClick="ResetButton(6)" onMouseOver="MM_swapImage('Image6','','../images/asBar_06-over.gif',1)" onMouseOut="MM_swapImgRestore(1)"><img src="../images/asBar_06.gif" name="Image6" width="120" height="27" border="0" id="Image6"></a></td>
<td height="16"><a href="#" onMouseOut="MM_swapImgRestore(1)" onMouseOver="MM_swapImage('Image7','','../images/asBar_07-over.gif',1)"><img src="../images/asBar_07.gif" alt="#" name="Image7" width="120" height="27" border="0" id="Image7"></a></td>
<td height="16"><a href="#" onMouseOut="MM_swapImgRestore(1)" onMouseOver="MM_swapImage('Image8','','../images/asBar_08-over.gif',1)"><img src="../images/asBar_08.gif" name="Image8" width="120" height="27" border="0" id="Image8"></a></td>
<td height="16"><a href="#" onMouseOut="MM_swapImgRestore(1)" onMouseOver="MM_swapImage('Image9','','../images/asBar_09-over.gif',1)"><img src="../images/asBar_09.gif" name="Image9" width="120" height="27" border="0" id="Image9"></a></td>
<td height="16"><img src="../images/asBar_10.gif" name="image10" width="119" height="27" id="image10"></td>
</tr>
I've got a set of buttons which have a SwapImageRestore happening on the onMouseOut, a simple rollover however what I want to happen is that when the button is clicked a function is called which swaps all the buttons, this I have working but after the function the onmouseout event is disabled until different button is clicked.
I tried dynamically setting the onMouseOut value of the button within the first function which changes the images however it seems not to change. Heres the code
The function which runs when the button is clicked:
function ResetButton(btno){
var imgno;
var x;
for(x=1;x<11;x++){
imgno="Image" + x;
if (btno==x)
{
document.images
document.images
}
if (x!=btno)
{
document.images
document.images
}
}
}
function MM_swapImgRestore(decide) {
if(decide==1){ //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}
}
The buttons *NOTE: I've only been testing with a couple of buttons so far ie. Image1, Image2
<tr>
<td width="120" height="16"><a href="asArch.asp" target="mainFrame" onMouseOut="MM_swapImgRestore(1)" onClick="ResetButton(1)" onMouseOver="MM_swapImage('Image1','','../images/asBar_01-over.gif',1)" ><img src="../images/asBar_01.gif" name="Image1" width="120" height="27" border="0" id="Image1"></a></td>
<td width="120" height="16"><a href="asQuanSurv.asp" onMouseOut="MM_swapImgRestore(1)" onClick="ResetButton(2)" onMouseOver="MM_swapImage('Image2','','../images/asBar_02-over.gif',1)" target="mainFrame"><img src="../images/asBar_02.gif" name="Image2" width="120" height="27" border="0" id="Image2"></a></td>
<td width="120" height="16"><a href="asBsEng.asp" onMouseOut="MM_swapImgRestore(1)" onMouseOver="MM_swapImage('Image3','','../images/asBar_03-over.gif',1)" target="mainFrame"><img src="../images/asBar_03.gif" name="Image3" width="120" height="27" border="0" id="Image3"></a></td>
<td width="116" height="16"><a href="asCivil.asp" onMouseOut="MM_swapImgRestore(1)" onMouseOver="MM_swapImage('Image4','','../images/asBar_04-over.gif',1)" target="mainFrame"><img src="../images/asBar_04.gif" name="Image4" width="120" height="27" border="0" id="Image4"></a></td>
<td width="124" height="16"><a href="asQualCont.asp" onMouseOut="MM_swapImgRestore(1)" onMouseOver="MM_swapImage('Image5','','../images/asBar_05-over.gif',1)" target="mainFrame"><img src="../images/asBar_05.gif" name="Image5" width="119" height="27" border="0" id="Image5"></a></td>
</tr>
<tr>
<td height="16"><a href="asIntDesign.asp" target="mainFrame" onClick="ResetButton(6)" onMouseOver="MM_swapImage('Image6','','../images/asBar_06-over.gif',1)" onMouseOut="MM_swapImgRestore(1)"><img src="../images/asBar_06.gif" name="Image6" width="120" height="27" border="0" id="Image6"></a></td>
<td height="16"><a href="#" onMouseOut="MM_swapImgRestore(1)" onMouseOver="MM_swapImage('Image7','','../images/asBar_07-over.gif',1)"><img src="../images/asBar_07.gif" alt="#" name="Image7" width="120" height="27" border="0" id="Image7"></a></td>
<td height="16"><a href="#" onMouseOut="MM_swapImgRestore(1)" onMouseOver="MM_swapImage('Image8','','../images/asBar_08-over.gif',1)"><img src="../images/asBar_08.gif" name="Image8" width="120" height="27" border="0" id="Image8"></a></td>
<td height="16"><a href="#" onMouseOut="MM_swapImgRestore(1)" onMouseOver="MM_swapImage('Image9','','../images/asBar_09-over.gif',1)"><img src="../images/asBar_09.gif" name="Image9" width="120" height="27" border="0" id="Image9"></a></td>
<td height="16"><img src="../images/asBar_10.gif" name="image10" width="119" height="27" id="image10"></td>
</tr>