telephonefield
04-08-2009, 08:22 PM
1) Script Title: ontoggle Event Handler
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse_suppliment.htm
3) Describe problem: Not really a problem, just wanting to know the best and most simple way to code something relative to the code already implemented for the ontoggle Event Handler.
Here's the code I have for the Event Handler so far, and it works perfect in that the togglers are given their respective images (either red or grey) when the linked divs are toggled. I just want to add some code that will exchange the image when rolled over (onmouseover) as well as when rolling out (onmouseout).
animatedcollapse.ontoggle=function($, divobj, state){
if (divobj.id=="pressefotos_big") //only react to this
document.getElementById(divobj.id+"-toggle").src=(state=="block")? "images/presse_nav/nav_button_pressefotos_r.jpg" : "images/presse_nav/nav_button_pressefotos_g.jpg"
if (divobj.id=="presseartikel_anzahl") //only react to this DIV
document.getElementById(divobj.id+"-toggle").src=(state=="block")? "images/presse_nav/nav_button_presseartikel_r.jpg" : "images/presse_nav/nav_button_presseartikel_g.jpg"
}
What makes it complicated is that the toggler that is ACTIVE (that is, in this case, red) should NOT go back to grey onmouseout, being that the div(s) are still active. (Every simple imageswap script I've tried has had this problem.)
So what code will ensure that the image is swapped on only the current non-active toggler (the active/red toggler shouldn't change when moused over, but the inactive toggler should change on both onmouseover and onmouseout.)
I'm just looking for something really simple as I'm sure this has been executed in countless other places... I'm just pretty new to all of it : ).
Thanks a lot!
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse_suppliment.htm
3) Describe problem: Not really a problem, just wanting to know the best and most simple way to code something relative to the code already implemented for the ontoggle Event Handler.
Here's the code I have for the Event Handler so far, and it works perfect in that the togglers are given their respective images (either red or grey) when the linked divs are toggled. I just want to add some code that will exchange the image when rolled over (onmouseover) as well as when rolling out (onmouseout).
animatedcollapse.ontoggle=function($, divobj, state){
if (divobj.id=="pressefotos_big") //only react to this
document.getElementById(divobj.id+"-toggle").src=(state=="block")? "images/presse_nav/nav_button_pressefotos_r.jpg" : "images/presse_nav/nav_button_pressefotos_g.jpg"
if (divobj.id=="presseartikel_anzahl") //only react to this DIV
document.getElementById(divobj.id+"-toggle").src=(state=="block")? "images/presse_nav/nav_button_presseartikel_r.jpg" : "images/presse_nav/nav_button_presseartikel_g.jpg"
}
What makes it complicated is that the toggler that is ACTIVE (that is, in this case, red) should NOT go back to grey onmouseout, being that the div(s) are still active. (Every simple imageswap script I've tried has had this problem.)
So what code will ensure that the image is swapped on only the current non-active toggler (the active/red toggler shouldn't change when moused over, but the inactive toggler should change on both onmouseover and onmouseout.)
I'm just looking for something really simple as I'm sure this has been executed in countless other places... I'm just pretty new to all of it : ).
Thanks a lot!