Page 1 of 1

[javascript] Hover on mouseover ::solved::

Posted: Sun Sep 04, 2005 9:23 pm
by Skara
Getting a strange error.

Code: Select all

<img alt='' src='kitchen_1/4.jpg' name='4' onmouseover='lightup("kitchen_1/4");' onmouseout='lightoff("kitchen_1/4");' />

Code: Select all

function lightup(imgName) {
  document[imgName].src= eval(imgName + "s.jpg");
}
function lightoff(imgName) {
  document[imgName].src= eval(imgName + ".jpg");
}
I get this in my error console:
Error: missing ; before statement
Source File: --omitted--
Line: 2, Column: 11
Source Code:
kitchen_1/4s.jpg

I need this to be really simple. I'm going to have 50--give or take--files that auto-create the images and such for different rooms.
e.g.

Code: Select all

print ('...stuff here...' . img(4,true) . '...more stuff...');
where 'true' makes it a hover image. Simple. :)

Posted: Sun Sep 04, 2005 9:31 pm
by feyd
lose the eval(), you don't need it. Strings combine together without issue.

Posted: Sun Sep 04, 2005 10:02 pm
by Skara
aha. Dunno why I put that there. :P Thanks.