/    Sign up×
Community /Pin to ProfileBookmark

Duplicate Dropdown

I am working on a website that has a dropdown box at the top and bottom of the page. I want to make it so that if a user selects an item from the top or bottom dropdown, the change is reflected in the opposite dropdown.

For example say each dropdown has 2 selections (Yes and No). If a user changes either box to “No”, the both boxes would display “No”.

I found this code, but i am not sure how to implement it, or if it is even the right thing for what I am trying to do.

[CODE]
<script language=”javascript”>
<!–
function setSelect (name1, name2) {
var select1 = document.forms.formname.elements[name1];
var select2 = document.forms.formname.elements[name2];
select1.selectedIndex = select2.selectedIndex;
}
//–>
</script>
[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterFeb 22.2005 — Here try:
[size=-3]
&lt;script language="javascript"&gt;
&lt;!--
function setSelect (name1,name2) {
name2.selectedIndex=name1.selectedIndex
}
//--&gt;
&lt;/script&gt;

&lt;form name="form1"&gt;

&lt;select name="selecter1" onchange="setSelect(this,document.form1.selecter2)"&gt;
&lt;option value="YES"&gt;YES&lt;/option&gt;
&lt;option value="NO"&gt;NO&lt;/option&gt;
&lt;/select&gt;

&lt;select name="selecter2" onchange="setSelect(this,document.form1.selecter1)"&gt;
&lt;option value="YES"&gt;YES&lt;/option&gt;
&lt;option value="NO"&gt;NO&lt;/option&gt;
&lt;/select&gt;

&lt;/form&gt;
[/size]
Copy linkTweet thisAlerts:
@NinjabucketauthorFeb 22.2005 — Awesome!! That works perfectly thanks!
×

Success!

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