/    Sign up×
Community /Pin to ProfileBookmark

How to Reference HTML Object to display slideshow captions from Javascript

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>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@pyroOct 14.2003 — 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]
×

Success!

Help @dan4r spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...