alt view for images in an array

R

Rick

How would you create a different alt view for each image in the following?

<script language="JavaScript">
var i = 1;
banner1= new Image();
banner1.src = "image1jpg";
banner2= new Image();
banner2.src = "image2.jpg";



var links = new Array

links[1] = "http://www.centerforplantconservation.org/testing/image1.jpg"
links[2] = "http://www.centerforplantconservation.org/testing/image2.jpg"



function loadBanner(){

var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
closeTime=hours*3600+mins*60+secs;

// Change this number to increase decrease the rotation speed
closeTime+=3;

Timer();

}

function Timer(){
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
curTime=hours*3600+mins*60+secs
if (curTime>=closeTime){
if (i < 5){
i++;
document.banner.src = eval("banner" + i +
".src");
}
else{
i = 1;
document.banner.src = eval("banner" + i +
".src");
} loadBanner();
}
else{
window.setTimeout("Timer()",1000)}

}

function clickLink(){
top.location = links
}

function changeAlt(){
var image = ??????
??????
}

</script>
 
J

Jim Ley

document.banner.src = eval("banner" + i +
".src");

don't use eval, don't just use document.

so:

document.images['banner'].src=window['banner'+i].src
document.images['banner'].alt=window['banner'+i].alt

for alt and src.

Jim.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top