muppetgrrl
Programmer
I tried posting about this last week; here's hoping someone might figure it out this time.
The following slideshow shows the image caption; advances prev and next as it's supposed to; and shows the proper-sized BORDER of the image. But it doesn't show the image, just a blank space. Any ideas?
//make an array of images
var imageCaption = new Array(
"Add a new project",
"Enter a project number, no decimals.",
"Save the project info.",
"View the summary of the project.");
//make a counter
var counter = 0;
var imgNum = imageCaption.length - 1;
var imageArray = new Array(imgNum);
for (var i=0; i < imgNum;i++)
{
imageArray = "image" + i + ".gif";
}
//preload function
function preLoad()
{
// make an image object variable
//loop through array of images and preLoad each
for (var i=0; i < imgNum;i++)
{
var imgPreload = new Image;
imgPreload.src = "image" + i + ".gif";
}
document.getElementById("imgNum").innerHTML = "Image 1 of " + imgNum
document.getElementById("caption").innerHTML = imageCaption[0]
}
//function to move forward in the slideshow
function nextImage()
{
//test counter
if (counter < imgNum)
{
//add one to counter if not to end of array
counter++;
}
else
{
//reset counter
counter = 0;
}
//show an image from the array.
document.slide.src = imageArray[counter];
var imgCount = counter + 1
document.getElementById("caption").innerHTML = imageCaption[counter]
document.getElementById("imgNum").innerHTML = "Image " + imgCount + " of " + imgNum
}
//function to move back in the slideshow
function prevImage()
{
//test counter
if (counter > 0)
{
//subtract one from counter if not 0
counter--;
}
else
{
//subtract one from the length of the array
counter = imgNum - 1;
}
{
//show an image from the array.
document.slide.src = imageArray[counter];
var imgCount = counter + 1
document.getElementById("caption").innerHTML = imageCaption[counter]
document.getElementById("imgNum").innerHTML = "Image " + imgCount + " of " + imgNum
}
}
//-->
</script>
</head>
<body onload="preLoad();">
<noscript>
You must have Javascript enabled to view the slideshow.
</noscript>
<table align="center">
<tr>
<td name="caption" id="caption" width="500" colspan="2" height="50" class="headerBlack" valign="middle">Add a new project.</td>
</tr>
<tr>
<td height="1" width="500" bgcolor="#008080" colspan="2"></td>
</tr>
<tr>
<td width="250" height="25" name="imgNum" id="imgNum" align="left"></td>
<td width="250" height="25" align="right">
<a href="javascript:;" onclick="prevImage();"><< Previous</a> | <a href="javascript:;" onclick="nextImage();">Next >></a></td>
</tr>
<tr>
<td width="500" colspan="2" height="400" align="center" valign="center">
<img name="slide" id="slide" src="image1.gif" alt="Click for next image" border="1">
</td>
</tr>
</table>
The following slideshow shows the image caption; advances prev and next as it's supposed to; and shows the proper-sized BORDER of the image. But it doesn't show the image, just a blank space. Any ideas?
//make an array of images
var imageCaption = new Array(
"Add a new project",
"Enter a project number, no decimals.",
"Save the project info.",
"View the summary of the project.");
//make a counter
var counter = 0;
var imgNum = imageCaption.length - 1;
var imageArray = new Array(imgNum);
for (var i=0; i < imgNum;i++)
{
imageArray = "image" + i + ".gif";
}
//preload function
function preLoad()
{
// make an image object variable
//loop through array of images and preLoad each
for (var i=0; i < imgNum;i++)
{
var imgPreload = new Image;
imgPreload.src = "image" + i + ".gif";
}
document.getElementById("imgNum").innerHTML = "Image 1 of " + imgNum
document.getElementById("caption").innerHTML = imageCaption[0]
}
//function to move forward in the slideshow
function nextImage()
{
//test counter
if (counter < imgNum)
{
//add one to counter if not to end of array
counter++;
}
else
{
//reset counter
counter = 0;
}
//show an image from the array.
document.slide.src = imageArray[counter];
var imgCount = counter + 1
document.getElementById("caption").innerHTML = imageCaption[counter]
document.getElementById("imgNum").innerHTML = "Image " + imgCount + " of " + imgNum
}
//function to move back in the slideshow
function prevImage()
{
//test counter
if (counter > 0)
{
//subtract one from counter if not 0
counter--;
}
else
{
//subtract one from the length of the array
counter = imgNum - 1;
}
{
//show an image from the array.
document.slide.src = imageArray[counter];
var imgCount = counter + 1
document.getElementById("caption").innerHTML = imageCaption[counter]
document.getElementById("imgNum").innerHTML = "Image " + imgCount + " of " + imgNum
}
}
//-->
</script>
</head>
<body onload="preLoad();">
<noscript>
You must have Javascript enabled to view the slideshow.
</noscript>
<table align="center">
<tr>
<td name="caption" id="caption" width="500" colspan="2" height="50" class="headerBlack" valign="middle">Add a new project.</td>
</tr>
<tr>
<td height="1" width="500" bgcolor="#008080" colspan="2"></td>
</tr>
<tr>
<td width="250" height="25" name="imgNum" id="imgNum" align="left"></td>
<td width="250" height="25" align="right">
<a href="javascript:;" onclick="prevImage();"><< Previous</a> | <a href="javascript:;" onclick="nextImage();">Next >></a></td>
</tr>
<tr>
<td width="500" colspan="2" height="400" align="center" valign="center">
<img name="slide" id="slide" src="image1.gif" alt="Click for next image" border="1">
</td>
</tr>
</table>