[javascript] Hover on mouseover ::solved::

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

[javascript] Hover on mouseover ::solved::

Post 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. :)
Last edited by Skara on Sun Sep 04, 2005 10:02 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

lose the eval(), you don't need it. Strings combine together without issue.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

aha. Dunno why I put that there. :P Thanks.
Post Reply