M
[Mr.] Lynn Kurtz
I have a sequence of four document.write commands that work. The
swap() function swaps in a new picture and the carstages array is a
list of what the picture represents. So you under the picture you geth
a line of text links links on which to click to see the next picture.
And it all works (Yay!!).
But here's my question-- when I comment out the four individual
instructions and replace them with the loop, I get a picture, but I
don't get the line of links underneath anymore to click on. Probably
something stupid, but I never claimed to be an expert. :-(
Any suggestions? Here's the code (this is in the body section):
<script>type="text/javascript">
// problem with this loop:
// for(j = 0; j < carstages.length; j++)
// document.write('<a ' + 'href="javascript:swap(j)">'
// + '<em>'+ carstages[j] + '<\/em>'+ '<\/a>'+' ');
document.write('<a ' + 'href="javascript:swap(0)">'
+ '<em>'+ carstages[0] + '<\/em>'+ '<\/a>'+' ');
document.write('<a ' + 'href="javascript:swap(1)">'
+ '<em>'+ carstages[1] + '<\/em>' + '<\/a>'+' ');
document.write('<a ' + 'href="javascript:swap(2)">'
+ '<em>'+ carstages[2] + '<\/em>' + '<\/a>'+' ');
document.write('<a ' + 'href="javascript:swap(3)">'
+ '<em>'+ carstages[3] + '<\/em>' + '<\/a>'+' ');
document.write('<a ' + 'href="javascript:swap(4)">'
+ '<em>'+ carstages[4] + '<\/em>' + '<\/a>'+' ');
</script>
The swap function is in the header:
function swap(imgIndex)
}
document['imgMain'].src = carimages[imgIndex];
}
and the carstages array is just an array of strings.
Thanks.
--Lynn
swap() function swaps in a new picture and the carstages array is a
list of what the picture represents. So you under the picture you geth
a line of text links links on which to click to see the next picture.
And it all works (Yay!!).
But here's my question-- when I comment out the four individual
instructions and replace them with the loop, I get a picture, but I
don't get the line of links underneath anymore to click on. Probably
something stupid, but I never claimed to be an expert. :-(
Any suggestions? Here's the code (this is in the body section):
<script>type="text/javascript">
// problem with this loop:
// for(j = 0; j < carstages.length; j++)
// document.write('<a ' + 'href="javascript:swap(j)">'
// + '<em>'+ carstages[j] + '<\/em>'+ '<\/a>'+' ');
document.write('<a ' + 'href="javascript:swap(0)">'
+ '<em>'+ carstages[0] + '<\/em>'+ '<\/a>'+' ');
document.write('<a ' + 'href="javascript:swap(1)">'
+ '<em>'+ carstages[1] + '<\/em>' + '<\/a>'+' ');
document.write('<a ' + 'href="javascript:swap(2)">'
+ '<em>'+ carstages[2] + '<\/em>' + '<\/a>'+' ');
document.write('<a ' + 'href="javascript:swap(3)">'
+ '<em>'+ carstages[3] + '<\/em>' + '<\/a>'+' ');
document.write('<a ' + 'href="javascript:swap(4)">'
+ '<em>'+ carstages[4] + '<\/em>' + '<\/a>'+' ');
</script>
The swap function is in the header:
function swap(imgIndex)
}
document['imgMain'].src = carimages[imgIndex];
}
and the carstages array is just an array of strings.
Thanks.
--Lynn