PDA

View Full Version : How do you mix scripts?



luceduce
10-03-2008, 03:05 AM
http://www.dynamicdrive.com

I need to have 2 scripts on one PHP page. What's the coding to mix them up together so they still function correctly?

I've seen it before, just cannot remember which page I've seen it on.....sorry if this is a repost.

rangana
10-03-2008, 03:17 AM
Which scripts? Please provide a URL.

Ensure that there are no two variables that are the same on the two scripts.

Be careful of the onload event, you can call multiple functions within one onload event, but you cannot use multiple onload event as the later overrides the first.

Hope that makes sense.

luceduce
10-03-2008, 04:06 AM
WoW! Quick response... :)

I believe that this is where I'm having the errors...if you can find an error or more in here, please let me know where!

Thank you, much appreciated.




<link rel="stylesheet" type="text/css" href="/scripts/thumbnailviewer.css" />
<script type="text/JavaScript">
<!--
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_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_findObj(n, d) { //v4.01
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);
if(!x && d.getElementById) x=d.getElementById(n); 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>

<script type="text/javascript"><!--
function resize()
{
resizeTo(700, 600);
}
//-->
</script>
</head>

<body onload="MM_preloadImages('../images/weddingbandssmall.gif')">
<div id="Header">
<div align="center" class="title style4">Sandra Johnson & Michael Gladstone</div>
<div class="date" align="center">September 14th, 2008</div>
</div>
<div id="SideLinks">
<div class="links">
<div align="right">
<table width="200" height="252" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="171" align="right"><img src="../images/links/homepage.gif" name="Homepage" width="82" height="17" border="0" id="Homepage" onmouseover="MM_swapImage('homepage','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="homepage" width="2" height="2" id="homepage" onmouseover="MM_swapImage('homepage','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td width="171" align="right"><img src="../images/links/theevent.gif" name="TheEvent" width="78" height="15" id="TheEvent" onmouseover="MM_swapImage('theevent','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="theevent" width="2" height="2" id="theevent" onmouseover="MM_swapImage('theevent','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<tr>
<td width="171" align="right"><img src="../images/links/journal.gif" name="Journal" width="56" height="15" id="Journal" onmouseover="MM_swapImage('journal','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="journal" width="2" height="2" id="journal" onmouseover="MM_swapImage('journal','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>

<td width="171" align="right"><img src="../images/links/ourstories.gif" name="OurStories" width="87" height="15" id="OurStories" onmouseover="MM_swapImage('ourstories','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="ourstories" width="2" height="2" id="ourstories" onmouseover="MM_swapImage('ourstories','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td width="171" align="right"><img src="../images/links/polls.gif" name="Polls" width="38" height="15" id="Polls" onmouseover="MM_swapImage('polls','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="polls" width="2" height="2" id="polls" onmouseover="MM_swapImage('polls','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td width="171" align="right"><img src="../images/links/quizzes.gif" name="Quizzes" width="61" height="18" id="Quizzes" onmouseover="MM_swapImage('quizzes','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="quizzes" width="2" height="2" id="quizzes" onmouseover="MM_swapImage('quizzes','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td width="171" align="right"><img src="../images/links/familyandfriends.gif" name="FamilyAndFriends" width="148" height="18" id="FamilyAndFriends" onmouseover="MM_swapImage('familyandfriends','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="familyandfriends" width="2" height="2" id="familyandfriends" onmouseover="MM_swapImage('familyandfriends','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td width="171" align="right"><img src="../images/links/theweddingparty.gif" name="TheWeddingParty" width="147" height="18" id="TheWeddingParty" onmouseover="MM_swapImage('theweddingparty','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="theweddingparty" width="2" height="2" id="theweddingparty" onmouseover="MM_swapImage('theweddingparty','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td width="171" align="right"><img src="../images/links/photoalbums.gif" name="PhotoAlbums" width="109" height="15" id="PhotoAlbums" onmouseover="MM_swapImage('photoalbums','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="photoalbums" width="2" height="2" id="photoalbums" onmouseover="MM_swapImage('photoalbums','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td width="171" align="right"><img src="../images/links/videos.gif" name="Videos" width="53" height="15" id="Videos" onmouseover="MM_swapImage('videos','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="videos" width="2" height="2" id="videos" onmouseover="MM_swapImage('videos','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td width="171" align="right"><img src="../images/links/giftregistry.gif" name="GiftRegistry" width="99" height="18" id="GiftRegistry" onmouseover="MM_swapImage('giftregistry','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="giftregistry" width="2" height="2" id="giftregistry" onmouseover="MM_swapImage('giftregistry','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td width="171" align="right"><img src="../images/links/thankyou.gif" name="ThankYou" width="83" height="15" id="ThankYou" onmouseover="MM_swapImage('thankyou','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="thankyou" width="2" height="2" id="thankyou" onmouseover="MM_swapImage('thankyou','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td width="171" align="right"><img src="../images/links/guestbook.gif" name="Guestbook" width="82" height="15" id="Guestbook" onmouseover="MM_swapImage('guestbook','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="guestbook" width="2" height="2" id="guestbook" onmouseover="MM_swapImage('guestbook','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
<tr>
<td width="171" align="right"><img src="../images/links/contactus.gif" name="ContactUs" width="85" height="14" id="ContactUs" onmouseover="MM_swapImage('contactus','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
<td width="29" align="center"><img src="../images/weddingbandsdot.gif" name="contactus" width="2" height="2" id="contactus" onmouseover="MM_swapImage('contactus','','../images/weddingbandssmall.gif',1)" onmouseout="MM_swapImgRestore()" /></td>
</tr>
</table>
</div>

luceduce
10-03-2008, 04:09 AM
Forgot to mention there's these lines at the end too which might have something to do with the scripts not functioning correctly...but I'm not sure.




<!--provide a close button-->
<p style="width:15%;margin:auto;border:1px solid #ccc;" align="center">
<a class="run2" href="javascript:window.close();">CLOSE<a/></p>

rangana
10-03-2008, 04:15 AM
Which one is not working? What's wrong?

For your problem, try to download Firebug to see what the error is.

Also note that close method (window.close()) only work to window's that were opened via open method (window.open()).

luceduce
10-03-2008, 04:58 AM
What is Firebug?

Well, it's mainly the image swap/restore doesn't work right now.

And I'm getting an error message for my guestbook script too, but I believe that this error is with the server only, so nothing to do with error in coding.