...

View Full Version : Javascript w/ rotating images - not working



snitz427
05-06-2004, 08:42 PM
Hello! I'm pretty new to webmastering in general, and brand spanking new to Javascript! I got this script off of a free resource site. It is supposed to be 9 tables. 4 cells on top, 4 cells on bottom, and one large cell spanning accross the 4. The cells are supposed to rotate, in that when you click on one of the cells (all except the large center cell) it should rotate itself into the center cell. The cell contents are loading up fine, however when you try to click on one of the cells (images) instead of putting the same image into the large center cell, the center image shows a "red x" instead of the image.

I don't know the code well enough to understand it or to try to manipulate it. If anyone could please help me, I would be so grateful!!! Here is the coding, or you can view source at www.corradoclubmd.com/gallery.html
(the script is still up on the page so you can see what problem I'm trying to describe).

The code:
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Jenny Blewitt (webmaster@webdesignsdirect.com) -->
<!-- Web Site: http://www.webdesignsdirect.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

ns3up = (browserName == "Netscape" && browserVer >= 3);
ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);

function doPic(imgName) {
if (ns3up || ie4up) {
imgOn = ("" + imgName);
document.mainpic.src = imgOn;
}
}
// End -->
</script>
</head>


<body>
<center>
<table width=360 border=0 cellspacing=0 cellpadding=0>
<tr>
<td><a href="javascript:doPic('p1.jpg');"><img src="/images/nataliem/car 105.jpg" width=90 height=60 border=0></a></td>
<td><a href="javascript:doPic('p2.jpg');"><img src="/images/nataliem/car 106.jpg" width=90 height=60 border=0></a></td>
<td><a href="javascript:doPic('p3.jpg');"><img src="/images/nataliem/car 107.jpg" width=90 height=60 border=0></a></td>
<td><a href="javascript:doPic('p4.jpg');"><img src="/images/nataliem/interior4.jpg" width=90 height=60 border=0></a></td>
</tr>
<tr>
<td colspan=4 align=center><img name="mainpic" src="/images/nataliem/car 108.jpg" width=360 height=240 border=0></td>
</tr>
<tr>
<td><a href="javascript:doPic('p5.jpg');"><img src="/images/nataliem/corrado.jpg" width=90 height=60 border=0></a></td>
<td><a href="javascript:doPic('p6.jpg');"><img src="/images/nataliem/corrado3.jpg" width=90 height=60 border=0></a></td>
<td><a href="javascript:doPic('p7.jpg');"><img src="/images/nataliem/engine.jpg" width=90 height=60 border=0></a></td>
<td><a href="javascript:doPic('p8.jpg');"><img src="/images/nataliem/Left Side.JPG" width=90 height=60 border=0></a></td>
</tr>
</table>
</center>


<!-- Script Size: 2.00 KB -->
</body>



Thank you thank you thank you thank you!
Natalie :eek:

Roy Sinclair
05-06-2004, 09:27 PM
The script is working fine, you've not put the right names for the images in place though.



<a href="javascript:doPic('p1.jpg');"><img src="/images/nataliem/car 105.jpg" width=90 height=60 border=0></a></td>


The red text above points to an image that simply doesn't exist, if you replace that with the blue text which points to the image you want then the script will work (for that particular image, how to fix the rest should now be obvious though).

snitz427
05-06-2004, 09:32 PM
Thanks so much! That was pretty obvious, now I feel like a doofus! :p
Thanks for taking the time to respond!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum