Click to See Complete Forum and Search --> : Need Javascript help!


bfox14612
02-19-2003, 03:19 PM
I am having a problem. I am still at the learning stage. But I am trying to make a form. This is really hard for me to explain.

I am trying to get (3) javascripts on one page. I have a template that I use in the car business that I am trying to implement. You are able to click on thumbnails and the picture blows up without opening another page. Anyway, I am trying to get three of these on one page. But after I copy the code and paste it three times, the javascript stops working. What am I doing wrong? Please help!

pyro
02-19-2003, 03:22 PM
Post your code. You probably have variable/function names that are the same.

bfox14612
02-19-2003, 03:29 PM
I am trying to get this on the page 3 times in a row. But the pictures won't do what they are doing now. The code is too long if I put in all in here. So what I am trying to do is to duplicate this 3 times all in one row across the page.


<SCRIPT language=JavaScript>
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//-->
</SCRIPT>
<!--Ebay Description-->
</HEAD>

<BODY style="MARGIN-TOP: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px" text=#000000
bgColor=#ffffff
onload="MM_preloadImages('/images/menubar_r1_c11_f2.gif','/images/menubar_r1_c13_f2.gif','/images/menubar_r1_c01_f2.gif','/images/menubar_r1_c03_f2.gif','/images/menubar_r1_c05_f2.gif','/images/menubar_r1_c07_f2.gif','/images/menubar_r1_c17_f2.gif','/images/menubar_r1_c09_f2.gif','/images/menubar_r1_c15_f2.gif')"
MARGINHEIGHT="0" MARGINWIDTH="0">
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center>
<TABLE cellSpacing=0 cellPadding=0 width=760 align=center bgColor=#6c6c6c
border=0 height="170">
<TBODY>
<TR>
<TD bgColor=#ffffff colSpan=2 height="19">&nbsp;</TD></TR>
<TR>
<TD vAlign=top align=left width=110 bgColor=#ffffff height=151>
<TABLE cellSpacing=0 cellPadding=0 width=120 align=center
border=0><TBODY>
<TR>
<TD width=115>
<SCRIPT language=JavaScript>
//<!--
document.write('<a href="javascript: a1(0)">')
//-->
</SCRIPT>
<NOSCRIPT><A
href="http://leasebyphone.com/Mvc-194s.jpg"></NOSCRIPT><IMG
height=45
src="http://leasebyphone.com/Mvc-194s.jpg"
width=60 align=middle border=0 color="#CCCCCC"></A></TD>
<TD width=115>
<SCRIPT language=JavaScript>
//<!--
document.write('<a href="javascript: a1(1)">')
//-->
</SCRIPT>
<NOSCRIPT><A
href="http://leasebyphone.com/Mvc-195s.jpg"></NOSCRIPT><IMG
height=45
src="http://leasebyphone.com/Mvc-195s.jpg"
width=60 align=middle border=0 color="#CCCCCC"></A></TD></TR>
<TR>
<TD width=115>
<SCRIPT language=JavaScript>
//<!--
document.write('<a href="javascript: a1(2)">')
//-->
</SCRIPT>
<NOSCRIPT><A
href="http://leasebyphone.com/Mvc-196s.jpg"></NOSCRIPT><IMG
height=45
src="http://leasebyphone.com/Mvc-196s.jpg"
width=60 align=middle border=0 color="#CCCCCC"></A></TD>
<TD width=115>
<SCRIPT language=JavaScript>
//<!--
document.write('<a href="javascript: a1(3)">')
//-->
</SCRIPT>
<NOSCRIPT><A
href="http://leasebyphone.com/Mvc-197s.jpg"></NOSCRIPT><IMG
height=45
src="http://leasebyphone.com/Mvc-197s.jpg"
width=60 align=middle border=0 color="#CCCCCC"> </A></TD></TR>
</TBODY></TABLE>
<P align=center>
<SCRIPT language=JavaScript>
//<!--
testurl = new Array(13);
testurl[0]="http://leasebyphone.com/Mvc-194s.jpg"
testurl[1]="http://leasebyphone.com/Mvc-195s.jpg"
testurl[2]="http://leasebyphone.com/Mvc-196s.jpg"
testurl[3]="http://leasebyphone.com/Mvc-197s.jpg"

function a1(photoIndex)
{
document['rollaround'].src = testurl[photoIndex];
return;
}
//-->
</SCRIPT>
<FONT face="Gill Sans MT" color=#000000
size=1>Click on Image for large view</FONT></P>
<P></P></TD>
<TD vAlign=top width=640 bgColor=#ffffff height=151>
<IMG height=90
src="http://leasebyphone.com/Mvc-194s.jpg"
width=187 border=0 name=rollaround
color="#CCCCCC"></TD></TR></TBODY></TABLE>
<DIV align=center>

</DIV></TD></TR></TBODY></TABLE></BODY></HTML>

pyro
02-19-2003, 06:41 PM
You should just have to add your function again, like this...

function a1(photoIndex)
{
document['rollaround'].src = testurl[photoIndex];
return;
}

function a2(photoIndex)
{
document['yourotherimage'].src = testurl[photoIndex];
return;
}

and then call it like this:

document.write('<a href="javascript: a2(4)">')with 4 being the number of your image in the testurl array.

Dan Drillich
02-22-2003, 06:08 PM
When you say -

three of these on one page

Do you mean that you -
1) want to see the same image three times.
2) want to see three different images.

If you speak about the second option, which 3 out of the 4 images should be displayed?