/    Sign up×
Community /Pin to ProfileBookmark

Change selected option

Hi!

I have six dropdown-lists (<select>) where the user can select a country related to a specific image – one dropdown per image. To make it easier for the user I also want to have a dropdown-list that changes the selected option in all the other dropdown-lists to the same value. How would I write this? I’m quite a rookie at JavaScript.

Thanks in advance.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERJun 11.2008 — Do you have some example code to look at and/or modify?

If you have the select boxes identified as SB0..SB5, and assuming SB0 is the control box, you could try ...
[code=php]
// in <HEAD>
function SetSB() {
var SBselect = document.getElementById('SB0').selectedIndex;
document.getElementById('SB1').selectedIndex = SBselect;
...
document.getElementById('SB5').selectedIndex = SBselect;
}

// in <BODY>
<input id="SB0" type="selectbox" onclick="SetSB()">
[/code]

Obviously untested.
Copy linkTweet thisAlerts:
@KorJun 11.2008 — Give us a significant piece of your HTML code
Copy linkTweet thisAlerts:
@coffe_eauthorJun 11.2008 — Thanks JMRKER, works just fine!
Copy linkTweet thisAlerts:
@JMRKERJun 11.2008 — Sometimes I just guess good! ?
×

Success!

Help @coffe_e 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.17,
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,
)...