/    Sign up×
Community /Pin to ProfileBookmark

Multiple Maps for Multiple Rotating Random Images

Please Help!

I have four images that I have to randomly rotate and I need to map the images to different links. I was able to find a script that randomly rotates the images, but the problem I am having is the four different maps. Each image is the same size and uses the same area coordinates, but they link to different urls. I tried adding the maps to the image arrays, that didn’t work. I tried an if/else, no lucky there either.

How do I get these images to map to the right links and still randomly rotate?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Willy_DuittOct 07.2004 — What are we suppose to be looking at??
Copy linkTweet thisAlerts:
@dragon2006authorOct 11.2004 — Change of plans, now I just need the images to random rotate when clicked or page is revisited/refreshed. Again, I can find the script for that. The problem I am having is incorporating the four maps that are to be used.

Here is what I have so far:

<html>

<head>

<title></title>

<script language="JavaScript">

var rand1 = 0;

var useRand = 0;

images = new Array;

images[1] = new Image();

images[1].src = "image1.jpg";

images[2] = new Image();

images[2].src = "image2.jpg";

images[3] = new Image();

images[3].src = "image3.jpg";

images[4] = new Image();

images[4].src = "image4.jpg";

function swapPic() {

var imgnum = images.length - 1;

do {

var randnum = Math.random();

rand1 = Math.round((imgnum - 1) * randnum) + 1;

} while (rand1 == useRand);

useRand = rand1;

document.randimg.src = images[useRand].src;

}

</script>

</head>

<body bgcolor="#ffffff" OnLoad="swapPic()">

<a href="page1.shtml" onclick="swapPic()"><img name="randimg" src="image1.jpg" alt="" width="567" height="161" border="0" usemap="#map1"></a><br>

<map name="map1">

<area alt="Click Here" coords="224,121,308,141" href="page1.shtml">

<area alt="Learn More" coords="384,124,448,142" href="page1a.shtml">

</map>

<!-- map 2-->
<img src="image2.jpg" alt="" width="567" height="161" border="0" usemap="#map2"><br>
<map name="map2">
<area alt="Click Here" coords="224,121,308,141" href="page2.shtml">
<area alt="Learn More" coords="384,124,448,142" href="page2a.shtml">
</map>


<!-- map 3-->
<img src="image3.jpg" alt="" width="567" height="161" border="0" usemap="#map3"><br>
<map name="map3">
<area alt="Click Here" coords="224,121,308,141" href="page3.shtml">
<area alt="Learn More" coords="384,124,448,142" href="page3a.shtml">
</map>

<!-- map 4-->
<img src="image4.jpg" alt="" width="567" height="161" border="0" usemap="#map4"><Br>
<map name="map4">
<area alt="Click Here" coords="224,121,308,141" href="image4.shtml">
<area alt="Learn More" coords="384,124,448,142" href="image4a.shtml">
</map>

</body>

</html>
×

Success!

Help @dragon2006 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...