I acquired a small javascript from a google search. I use this script to "scroll" jpeg images in a small webpage I run. [[[Disclaimer: I'm an ultra-n00b for javascript, yet I'm willing to learn and seek out the answers. Many searches and reading of tutorials later, I still can't get the right answer/solution. So if you can point me in the right direction, or help me figure out the solution, I'd greatly appreciate it.]]]
The small hiccup comes when I'd like to run two instances of these scripts: One with the images(JPEGs), and another with 'banners' (also JPEGs) linking to other parts of the site. When I try to place both scripts in the same page, neither script 'scrolls' the images.
Any ideas on where I'm messing up?
I include the code for the script at the end of the post/message.
Thank you very much for your time and help! =) Greatly appreciated!
I found this answered question in Stackoverflow, yet I can't seem to grasp around the solution: run 2 identical javascripts on the same page
Javascript code: (( the one I want to run two times ))
<p>
<script type="text/javascript">
theimage = new Array();
theimage[0]=["http://myWEBSITE.com/image01.jpg", "http://www.myWEBSITE.com", "myWEBSITE.com"];
theimage[1]=["http://myWEBSITE.com/image02.jpg", "http://www.myWEBSITE.com", "myWEBSITE.com"];
theimage[2]=["http://myWEBSITE.com/image03.jpg", "http://www.myWEBSITE.com", "myWEBSITE.com"];
theimage[3]=["http://myWEBSITE.com/image04.jpg", "http://www.myWEBSITE.com", "myWEBSITE.com"];
theimage[4]=["http://myWEBSITE.com/image05.jpg", "http://www.myWEBSITE.com", "myWEBSITE.com"];
theimage[5]=["http://myWEBSITE.com/image06.jpg", "http://www.myWEBSITE.com", "myWEBSITE.com"];
theimage[6]=["http://myWEBSITE.com/image07.jpg", "http://www.myWEBSITE.com", "myWEBSITE.com"];
theimage[7]=["http://myWEBSITE.com/image08.jpg", "http://www.myWEBSITE.com", "myWEBSITE.com"];
theimage[8]=["http://myWEBSITE.com/image09.jpg", "http://www.myWEBSITE.com", "myWEBSITE.com"];
theimage[9]=["http://myWEBSITE.com/image10.jpg", "http://www.myWEBSITE.com", "myWEBSITE.com"];
playspeed=1500;//
//###########################################
window.onload=function(){
preloadSlide();
SetSlide(0);
PlaySlide();
}
//###########################################
function SetSlide(num) {
i=num%theimage.length;
if(i<0)i=theimage.length-1;
document.images.imgslide.src=theimage[i][0];
document.getElementById('slidebox').innerHTML=theimage[i][2];
}
//###########################################
function PlaySlide() {
if (!window.playing) {
PlayingSlide(i+1);
if(document.slideshow.play){
document.slideshow.play.value=" Stop ";
}
}
else {
playing=clearTimeout(playing);
if(document.slideshow.play){
document.slideshow.play.value=" Play ";
}
}
if(document.images.imgPlay){
setTimeout('document.images.imgPlay.src="'+imgStop+'"',1);
imgStop=document.images.imgPlay.src
}
}
//###########################################
function PlayingSlide(num) {
playing=setTimeout('PlayingSlide(i+1);SetSlide(i+1);', playspeed);
}
//###########################################
function preloadSlide() {
for(k=0;k<theimage.length;k++) {
theimage[k][0]=new Image().src=theimage[k][0];
}
}
</script>
<!-- slide show HTML -->
<form name="slideshow">
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td align="center">
<a href="http://myWEBSITE.com/#" onmouseover="this.href=theimage[i][1];return false">
<script type="text/javascript">
document.write('<img name="imgslide" id="imgslide" src="'+theimage[0][0]+'" border="0">')
</script>
</a>
</td>
</tr>
<tr>
<td align="center"><div id="slidebox"></div></td>
</tr>
<tr>
<td align="center">
<input type="button" value="<<" onclick="SetSlide(i-1);" title="Previous image">
<input type="button" name="play" value=" Play " onclick="PlaySlide();" title="Autoplay">
<input type="button" value=">>" onclick="SetSlide(i+1);" title="Jump to next image">
</td>
</tr>
</table>
</form>
<!-- end of slide show HTML -->
</p>