Click to See Complete Forum and Search --> : Using Javascript var as input to HTML IMG arg.


KayC4
04-08-2003, 03:42 PM
Hi!

I'm a newbie to Javascript and I'm hoping someone here can help me with my programming problem!

I have an html file that contains an IMG tag that has a "USEMAP" argument. I would like to be able to use a variable for the USEMAP. Here's an example:

I have two maps:
<map name=map1>
<area ....>
<area ....>
</map>
<map name=map2>
<area ....>
<area ....>
</map>

Later in the html I have this img tag

<img src="filename.jpg" name="image" usemap="<here is where I'd like to use a variable">

Still later in the html

<a href="file.html" onMouseover="document.images['image'].src='newimage1.jpg'; return true;">Link 1</a>
<a href="file2.html"
onMouseover="document.images['image'].src='newimage2.jpg'; return true;">Link 2</a>

So that when the user puts his/her mouse over "Link1," the image formerly known as 'filename.jpg' is replaced by 'newimage1.jpg' and would use map named 'map1'.

If the user then places the mouse over "Link2," the image would change and a new map would be used.

I'm stumped!! Any and all help that you can provide would be GREATLY appreciated!!!

Thanks!

Kay

Jona
04-08-2003, 04:12 PM
Where is the question mark? :p I don't quite understand. Shouldn't what you just posted work? USEMAP="#mapName" should work...

khaki
04-08-2003, 04:20 PM
just an FYI

double-post
http://forums.webdeveloper.com/showthread.php?s=&threadid=7440

Jona
04-08-2003, 04:28 PM
Yah, I realized that... A lot (too many) people do that...

khaki
04-09-2003, 02:59 PM
I don't mean to turn this into a round-robin... but it's back in the Javscript forum with a slightly different take :rolleyes:

http://forums.webdeveloper.com/show...=&threadid=7497

yup.... still nuts...
;) k

Jona
04-09-2003, 03:26 PM
Not anymore! ;)