Click to See Complete Forum and Search --> : [RESOLVED] Mouseover events in a function.


kungfu71186
04-20-2006, 10:30 PM
Hopefully this makes sense.

Ok, i have a checkbox right now that will turn off and on an image. Now the the image has a tooltip on it too. When i shut the image i want to be able to change the tooltip on another image. So i got this, chkitem is the check box and setitem is the picture id. Now for the tooltips its currently setup as
onmouseover="stm(Text[0],Style[0])"



function setsh(chkitem,setitem){
if(document.getElementById(chkitem).checked == true){
document.getElementById(setitem).style.display = 'block';
}
else if(document.getElementById(chkitem).checked == false){
document.getElementById(setitem).style.display = 'none';
}
}


That is another function that im using for whats in the tooltip and the style of it. I have Text[0] defined as well as style[0].

But say i wanted to change the text to another one for a picture such as.

Picture1 - Text[0],Style[0]
Picture2 - Text[1],Style[0]

Now i shut off picture1 and i want to change picture2 to Text[2],Style[0]
just for testing i tried this.


function setsh(chkitem,setitem){
if(document.getElementById(chkitem).checked == true){
document.getElementById(setitem).style.display = 'block';
}
else if(document.getElementById(chkitem).checked == false){
document.getElementById(setitem).style.display = 'none';
document.getElementById('set2').onmouseover = 'stm(Text[2],Style[0])';
}
}


where set2 is the picture2 id. This does not seem to work for some reason. Anyone know why?

kungfu71186
04-21-2006, 10:30 AM
Bump, let me know if you dont understand and ill show an example of what im trying to do.

Orc Scorcher
04-21-2006, 11:12 AM
If you define event handlers this way then you must set them to a function, not a string. Use document.getElementById('set2').onmouseover = function () { stm(Text[2],Style[0]) }

kungfu71186
04-21-2006, 11:26 AM
well stm is a function, its calling stm and i want to change the variables to those now.

<input width="55" type="image" height="55" id="set2" onmouseover="stm(Text[0],Style[0])" onmouseout="htm()" src="pic.jpg" />

i have something like this, that works fine. But when i call that function i made the setsh, i want it to change the onmouseover to stm(Text[2],Style[0]) instead of what it was before.

Orc Scorcher
04-21-2006, 12:18 PM
'stm(Text[2],Style[0])'; is a string. Setting event handlers from script is quite different from setting an event attribute in HTML. Have you even tried my suggestion?

kungfu71186
04-21-2006, 01:24 PM
oh ok got ya, yea im actually going to do it a different. Im going to call another function first so i check somethings and depending what it founds it will use a different text. Thanks though.