Excuse the huge long post, but here's some code to test with. Basically, my function swapme() will show/hide the DIV, but if I include the ID tag in the <img ... /> tag it won't do anything at all. I am guessing that something is causing a javascript error and its just failing to run totally, but I've googled the code and found one that works with nearly identical line. The pictures are definitely in that path as you can see it referenced. Any help please? I'm very very new to javascript and have no idea how to even begin to debug this and chase down the fault with it. (NOW REMOVED AS ITS RESOLVED )
But I don't need to use any javascript tools for something as simple as this surely? All I wanted to do was swap an image when you click the link. The image swapper doesn't work at all even when I remove the DIV swapping, but the DIV swapping works fine, and I can't see why! It doesn't even fire a javascript error, it just doesn't work!
Simple mistake my friend, in the javascript file the second "if" statement should be an "else if", at the moment both if statements are coming up as true (the first executes, and causes the second to be true). New script: Code: function swapme(title) { var swapimg = "img_" + title; var swapdiv = "div_" + title; if (document.getElementById(swapdiv).style.display == "none") { document.getElementById(swapdiv).style.display = "block"; document.getElementById(swapimg).src = "skin/global/expanded.png"; } else if (document.getElementById(swapdiv).style.display == "block") { document.getElementById(swapdiv).style.display = "none"; document.getElementById(swapimg).src = "skin/global/collapsed.png"; } } I've been coding JS for over 7 years, and I still make mistakes like that
You sir, are a genius, thank you I knew it had to be something ridiculously obvious!!! Works wonderfully now I know its only a little thing, but when programming a cascading menu function you like to make sure the little touches are present Original code removed now so I guess this thread won't make much sense!