Click to See Complete Forum and Search --> : How to Reference HTML Object to display slideshow captions from Javascript


dan4r
10-14-2003, 02:38 PM
Hi,

I'm wondering how to display my slideshow captions. Setting ALT & TITLE tags below works fine, but I get an error when I try to change the value of the TextArea Object.

Please let me know if there is a better HTML object out there that I can use to display text from Javascript.

Here is the code.

myPix = new Array("http://www.tenderloinreading.com/picload/chuck.jpg","http://www.tenderloinreading.com/picload/evesimon.jpg")
myCaption = new Array("Chuck TEaches the kids","TEst")

thisPic = 0
imgCt = myPix.length -1
function chgSlide(direction) {
if (document.images) {
thisPic = thisPic + direction
if (thisPic > imgCt) {
thisPic = 0
}
if (thisPic < 0) {
thisPic = imgCt
}
document.myPicture.src=myPix[thisPic]
document.myPicture.alt=myCaption[thisPic]
document.myPicture.title=myCaption[thisPic]
document.myText.value=myCaption[thisPic]


}
}




As you can see, I'm setting the ALT & TITLE tags of the IMG to the caption string successfully. However I'd like to set a textarea or other label below the img as well. Would appreciate any help with how to reference the apporpriate HTML object.


I'd like to use a textarea, but this doesn't seem to work

<TEXTAREA NAME=myText>abcd</TEXTAREA>

pyro
10-14-2003, 02:57 PM
Change the name to an ID on your textarea, and then change this line:

document.myText.value=myCaption[thisPic]

to:

document.getElementById("myText").value=myCaption[thisPic]