I found this online somewhere and used it load a random background inside a table id'd "shgbody". It works great:
But I need a simple onlick (a href type link) that will run a function for users to tour through the array of photos; similar to what microsoft has done with bing.com (to click through the different images).Code:<!-- var backgroundImages=new Array(9); backgroundImages[0]="html-homeimages/bk1.jpg"; backgroundImages[1]="html-homeimages/bk2.jpg"; backgroundImages[2]="html-homeimages/bk3.jpg"; backgroundImages[3]="html-homeimages/bk4.jpg"; backgroundImages[4]="html-homeimages/bk5.jpg"; backgroundImages[5]="html-homeimages/bk6.jpg"; backgroundImages[6]="html-homeimages/bk7.jpg"; backgroundImages[7]="html-homeimages/bk8.jpg"; backgroundImages[8]="html-homeimages/bk9.jpg"; backgroundImages[9]="html-homeimages/bk10.jpg"; onload=function(){ var e=(document.getElementById)?document.getElementById("shgbody"):(document.all)?document.all.myTableId:(document.layers)?document.myTableId:null; if(!e)return true; e.style.backgroundImage="url("+backgroundImages[Math.floor(Math.random()*backgroundImages.length)]+")"; } //-->
I've tried to create a function using the bottom portion of the scipt below, but java isn't as intuitive as VBA so I'm having a difficult time trying to understand or come up with anything that will work.
I was trying this:
<a href="#" "onClick="nextimage()">Click</a>Code:<!-- function nextimage() random_number= Math.floor(Math.random()* 9+1 ); if (random_number==0) { e.style.backgroundImages="html-homeimages/bk1.jpg"; } if (random_number==1) { e.style.backgroundImages="html-homeimages/bk2.jpg"; } if (random_number==2) { e.style.backgroundImages="html-homeimages/bk3.jpg"; } if (random_number==3) { e.style.backgroundImages="html-homeimages/bk4.jpg"; } if (random_number==4) { e.style.backgroundImages="html-homeimages/bk5.jpg"; } if (random_number==5) { e.style.backgroundImages="html-homeimages/bk6.jpg"; } if (random_number==6) { e.style.backgroundImages="html-homeimages/bk7.jpg"; } if (random_number==7) { e.style.backgroundImages="html-homeimages/bk8.jpg"; } if (random_number==8) { e.style.backgroundImages="html-homeimages/bk9.jpg"; } if (random_number==9) { e.style.backgroundImages="html-homeimages/bk1.jpg"; } -->
Can anyone tell me why this isn't working?



Reply With Quote


Bookmarks