Hello,
So I have found this wonderful script that works very nicely, it displays a new image on the 'next' or 'previous' button, (in a div called "MainImage") however, I am trying to add a function that will load a line of text in a div (called "xdiv") describing the picture.
<script language="JavaScript">
<!--
// Use the following variable to specify
// the number of images
var NumberOfImages = 3
var img = new Array(NumberOfImages)
img[0] = "image.jpg"
img[1] = "image1.jpg"
img[2] = "image2.jpg"
var imgNumber = 0
function NextImage()
{
imgNumber++
if (imgNumber == NumberOfImages)
imgNumber = 0
document.images["MainImage"].src = img[imgNumber]
}
function PreviousImage()
{
imgNumber--
if (imgNumber < 0)
imgNumber = NumberOfImages - 1
document.images["MainImage"].src = img[imgNumber]
}
//-->
</script>
this is what triggers it in the body:
<a href="javascript:PreviousImage()"><p><< previous project</p></a>
<a href="javascript:NextImage()"><p>next project >></p></a>
again, this script works like a charm, but I can't seem to even find a script that will call a different line of text on an event... so I am not even sure if I am trying to do something that is impossible?
I have no problem using something like an external text file attaching the name to the picture, I just have no idea how to attach it... It would be even better if I can attach some links to the text as well, or make the image clickable, but for now, I just want text to be displayed.
(oh and I have been playing with this a while, this is something that I just tried to see if it would work but it doesn't,)
<script language="JavaScript">
<!--
// Use the following variable to specify
// the number of images
var NumberOfDes = 3
var txt = new Array(NumberOfDes)
txt[0] = "text1"
txt[1] = "tetx2"
txt[2] = "tetx3"
var txtNumber = 0
function NextDescription()
{
txtNumber++
if (txtNumber == NumberOfDes)
txtNumber = 0
document.write["xDiv"].src = txt[txtNumber]
}
function PreviousDescription()
{
txtNumber--
if (txtNumber < 0)
txtNumber = NumberOfDes - 1
document.write["xDiv"].src = txt[txtNumber]
}
//-->
</script>
And even if it was close, how do I tie this in on the eventhandler?
Thanks for your time!
Bookmarks