I’m a real newbie with Javascript, but I’m having fun. I just bought the book, “Simply Javascript” (have only just cracked it so far). I’m reasonably familiar with PHP (I use a lot of it to do simple things). I’m a Web desinger and do custom CSS Websites (I’m fairly new to that too — couple of years or more working with CSS and I’ve never done a table based layout.
That’s my background. Here is what I’m working on and what I want to do. Ref. http://www.clydeconstructionservices.com.
I have a page on that site that shows current projects, and I have a maunally operated slide show (slight modification of the script that runs the show on the “Siding” page). I want to change some of the text as the images advance with the “Next” button. I’ve created an Image Object for each image:
<script type=“text/javascript”>
<!–
var image1=new Image()
image1.src=“/images/photos/completed_projects/P6010122.jpg”;
image1.caption=“A resided home is like a complete facelift.”;
var image2=new Image()
image2.src=“/images/photos/completed_projects/P6080127.jpg”;
image2.caption=“This is the garage”;
var autorun=“false”;
var count=15;
//–>
</script>
There are 15 images in this list.
Here is the slideshow script:
<!–
//variable that will increment through the images
var step=1
imgNum=eval(“step”)
function slideit(){
//if browser does not support the image object, exit.
if (!document.images)
return
document.images.slide.src=eval(“image”+step+“.src”)
if (step<count){
step++;
}
else {
step=1
}
var newVar=eval(“autorun”);
if (newVar==true) {
//call function "slideit()" every 3.0 seconds
setTimeout("slideit()",3000)
}
}
slideit()
// –>
I modified it slightly so that I can auto run it on the “Siding” page, and use a button to advance the photos on the “Recent Projects” page.
I think I realize what my main problem is: The page loads once, and runs the script to show the captions, once:
<!–
function showCaption() {
imgNum=eval(“step”);
document.write(“<p>Photo No. “+imgNum+”<br />”+eval(“image”+imgNum+“.caption”)+“</p>”);
}
showCaption()
// –>
But when the button is clicked, nothing will call the showCaption() function again, and I can’t figure out how to call that function as the images advance. I have tried a lot of things with a lot of weird results, one being the tne next caption will display in a blank browser window, without the Webpage! I’m not sure why that happens, but I have a clue.
Is there an easier way to do what I want to do? I only want to show a few lines of text that will describe each image. Seems simple enough to me, but I’m just too new to make it work.
Thanks in advance.
Bill Otis