/    Sign up×
Community /Pin to ProfileBookmark

Multiple Image + Dropdown

I’d like to use a dropdownmenu on my site, that shows different pictures (on the same page) depending the choice. So basicly it should be a combination of these 2 tutorials: [URL=http://www.htmlgoodies.com/beyond/javascript/article.php/3470881]this one[/URL] and [URL=http://www.htmlgoodies.com/beyond/javascript/stips/article.php/3471751]this one[/URL]

Anyone here who knows how to do this? (and is willing to tell me ? )

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinDec 13.2005 — do you already have an image on your page to start with?
Copy linkTweet thisAlerts:
@konithomimoDec 13.2005 — <i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;
function update(what)
{
selected = what.mySelect.selectedIndex;
values = what.mySelect.options[selected].value;
document.getElementById('myimage').src = values;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;select name="mySelect" onChange="update(this.form)"&gt;
&lt;option value="default.jpg"&gt;Choose an Image
&lt;option value="image1.jpg"&gt;Image 1
&lt;option value="image2.jpg"&gt;Image 2
&lt;option value="image3.jpg"&gt;Image 3
&lt;/select&gt;
&lt;img id="myimage" src="default.jpg"&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@TheblackadderauthorDec 23.2005 — thanks

wouldn't work at first, but all i needed to do was add <form > </form >
Copy linkTweet thisAlerts:
@konithomimoDec 23.2005 — yeah, sorry about that. I user this.form but forgot to put the select inside of a form.
×

Success!

Help @Theblackadder 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...