/    Sign up×
Community /Pin to ProfileBookmark

Problem getting array with pictures

Hey there,

I’ve been trying to make an array that shows pictures when users click a button. The code I’ve written was sort of based off a code I wrote previously, where the price would show up in a text box when users clicked a button. However, I’ve been unable to get it to work with pictures. This is the function I wrote:

[code=php]
disPictures = new Array(“filler2.jpg”, “hexigon.jpg”,”cedartraditional.jpg”,”bilevel.jpg”,”specialsizes.jpg”)
function setdisplayPictures(myForm) {
document.DeckMenu.DeckPic.value = “”
var listSelect = myForm.DeckList.selectedIndex
document.DeckMenu.DeckPic.value = disPictures[listSelect]
}[/code]

I placed onClick=”setdisplayPictures(DeckMenu)” in the button tag, where DeckMenu is the form name and DeckList is the selection list name. I also named the placeholder picture “DeckPic”.

Thanks for your help!

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceMay 23.2006 — If your placeholder is an IMG tag, then this:

document.DeckMenu.DeckPic.value = disPictures[listSelect]

should be this:

document.images["DeckPic"].src = disPictures[listSelect]
Copy linkTweet thisAlerts:
@cynrehauthorMay 24.2006 — Oh, thanks a bunch for your help!! It works great (but I feel like such an idiot now. :o ) Cheers.
Copy linkTweet thisAlerts:
@phpnoviceMay 24.2006 — You're welcome.

Cheers.
×

Success!

Help @cynreh 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.19,
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,
)...