Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable OnMouseOut after onClick

Status
Not open for further replies.

robrichardson

Programmer
Mar 14, 2001
86
GB
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=&quot;Image&quot; + 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= &quot;../images/asBar_0&quot; + x + &quot;.gif&quot;;
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=&quot;120&quot; height=&quot;16&quot;><a href=&quot;asArch.asp&quot; target=&quot;mainFrame&quot; onMouseOut=&quot;MM_swapImgRestore(1)&quot; onClick=&quot;ResetButton(1)&quot; onMouseOver=&quot;MM_swapImage('Image1','','../images/asBar_01-over.gif',1)&quot; ><img src=&quot;../images/asBar_01.gif&quot; name=&quot;Image1&quot; width=&quot;120&quot; height=&quot;27&quot; border=&quot;0&quot; id=&quot;Image1&quot;></a></td>
<td width=&quot;120&quot; height=&quot;16&quot;><a href=&quot;asQuanSurv.asp&quot; onMouseOut=&quot;MM_swapImgRestore(1)&quot; onClick=&quot;ResetButton(2)&quot; onMouseOver=&quot;MM_swapImage('Image2','','../images/asBar_02-over.gif',1)&quot; target=&quot;mainFrame&quot;><img src=&quot;../images/asBar_02.gif&quot; name=&quot;Image2&quot; width=&quot;120&quot; height=&quot;27&quot; border=&quot;0&quot; id=&quot;Image2&quot;></a></td>
<td width=&quot;120&quot; height=&quot;16&quot;><a href=&quot;asBsEng.asp&quot; onMouseOut=&quot;MM_swapImgRestore(1)&quot; onMouseOver=&quot;MM_swapImage('Image3','','../images/asBar_03-over.gif',1)&quot; target=&quot;mainFrame&quot;><img src=&quot;../images/asBar_03.gif&quot; name=&quot;Image3&quot; width=&quot;120&quot; height=&quot;27&quot; border=&quot;0&quot; id=&quot;Image3&quot;></a></td>
<td width=&quot;116&quot; height=&quot;16&quot;><a href=&quot;asCivil.asp&quot; onMouseOut=&quot;MM_swapImgRestore(1)&quot; onMouseOver=&quot;MM_swapImage('Image4','','../images/asBar_04-over.gif',1)&quot; target=&quot;mainFrame&quot;><img src=&quot;../images/asBar_04.gif&quot; name=&quot;Image4&quot; width=&quot;120&quot; height=&quot;27&quot; border=&quot;0&quot; id=&quot;Image4&quot;></a></td>
<td width=&quot;124&quot; height=&quot;16&quot;><a href=&quot;asQualCont.asp&quot; onMouseOut=&quot;MM_swapImgRestore(1)&quot; onMouseOver=&quot;MM_swapImage('Image5','','../images/asBar_05-over.gif',1)&quot; target=&quot;mainFrame&quot;><img src=&quot;../images/asBar_05.gif&quot; name=&quot;Image5&quot; width=&quot;119&quot; height=&quot;27&quot; border=&quot;0&quot; id=&quot;Image5&quot;></a></td>
</tr>
<tr>
<td height=&quot;16&quot;><a href=&quot;asIntDesign.asp&quot; target=&quot;mainFrame&quot; onClick=&quot;ResetButton(6)&quot; onMouseOver=&quot;MM_swapImage('Image6','','../images/asBar_06-over.gif',1)&quot; onMouseOut=&quot;MM_swapImgRestore(1)&quot;><img src=&quot;../images/asBar_06.gif&quot; name=&quot;Image6&quot; width=&quot;120&quot; height=&quot;27&quot; border=&quot;0&quot; id=&quot;Image6&quot;></a></td>
<td height=&quot;16&quot;><a href=&quot;#&quot; onMouseOut=&quot;MM_swapImgRestore(1)&quot; onMouseOver=&quot;MM_swapImage('Image7','','../images/asBar_07-over.gif',1)&quot;><img src=&quot;../images/asBar_07.gif&quot; alt=&quot;#&quot; name=&quot;Image7&quot; width=&quot;120&quot; height=&quot;27&quot; border=&quot;0&quot; id=&quot;Image7&quot;></a></td>
<td height=&quot;16&quot;><a href=&quot;#&quot; onMouseOut=&quot;MM_swapImgRestore(1)&quot; onMouseOver=&quot;MM_swapImage('Image8','','../images/asBar_08-over.gif',1)&quot;><img src=&quot;../images/asBar_08.gif&quot; name=&quot;Image8&quot; width=&quot;120&quot; height=&quot;27&quot; border=&quot;0&quot; id=&quot;Image8&quot;></a></td>
<td height=&quot;16&quot;><a href=&quot;#&quot; onMouseOut=&quot;MM_swapImgRestore(1)&quot; onMouseOver=&quot;MM_swapImage('Image9','','../images/asBar_09-over.gif',1)&quot;><img src=&quot;../images/asBar_09.gif&quot; name=&quot;Image9&quot; width=&quot;120&quot; height=&quot;27&quot; border=&quot;0&quot; id=&quot;Image9&quot;></a></td>
<td height=&quot;16&quot;><img src=&quot;../images/asBar_10.gif&quot; name=&quot;image10&quot; width=&quot;119&quot; height=&quot;27&quot; id=&quot;image10&quot;></td>
</tr>
 
Perhaps I didn't make myself too clear.

Ive decided to follow up with a link the site so you guys can see for yourself:

http:/floor2a.nps-property.co.uk/graphics/npsltd/index.asp

If you firstly click one of the five links at the top i.e. Architectural Services this displays a sub menu. I would like the roll overs to remain for all buttons however when one of the submenus is clicked it should remain in the onmouseover state (the other buttons still a normal rollover) until another button is clicked, the same should happen with each clicked button.

The idea is to inform the user where they are in the site.

I know this could be achieved by having a menu at the top of each page as opposed to having the links on the topframe with the main five buttons but Im trying to be efficient.

Any help would be appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top