B0b Posted June 13, 2009 Share Posted June 13, 2009 Hi, I'm begining in Javascript and I'm writing a simple website, something looking like a "skill" calculator for a PC game. I'm stuck in a bug (after 1000 some lines) and I really don't know what's the problem, please advise me... I got a couple of images that have onmouseover, onmouseout and onclick events. I want them to work just like a star rating system, but a bit more complex. So right now I'm stuck on the onmouseover. There's 3 types of images I got (selected (when it has been clicked), unselected (when it hasn't been onmouseover or clicked) and onmouseover (when it obviously has been mouseovered and not "mouseoutted"). I want the image to change OnMouseOver only it is not allready the "selected" image (if it hasn't been clicked). Here's the code: function do_pip_mouseover(pip) { switch (parseInt(pip)) { case 1: { document.getElementById(pip.substring(1) + "_score").innerHTML = "WTFFFFFFFFFFFF3453453453454"; if (document.getElementById("derbaran1").src == "/pip_unselected.png") { document.getElementById(pip.substring(1) + "_score").innerHTML = "WTFFFFFFFFFFFF"; document.getElementById("derbaran1").src = "/pip_mouseover.png"; } break; ... Ok so, in this, "pip" will return either "1derbaran", "2derbaran", "3derbaran" (up to 8 ) depending on the image clicked. So I'm doing a parseInt to know which one and I do a "switch" with this. Until then it work all good. If I mouse over the first, it will change the innerHTML to that "WTFFFFFFFFFFFF3453453453454" text (it was to test) BUT it will not do the rest (it won't change to the second text and change image). I mean the condition "if" after is false, but it should be true as the image I mouseover is this exact same URL (yes the folder and everything is good, I'm 100% sure and yes the element IS is "derbaran1"), the image of the first pip I mouseover is unselected. What's wrong? I have NO clues. Any ideas? Thanks. Quote Link to comment Share on other sites More sharing options...
B0b Posted June 13, 2009 Author Share Posted June 13, 2009 Nevermind, I found. When using an "if" with an image SRC, you need the full URL. Haaaaaaa Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.