/    Sign up×
Community /Pin to ProfileBookmark

javascript chained drop down menu can’t figure this out

I am trying to create 2 different drop down menus which are chained.

First drop down menu: options 1, 2, 3, and 4

Second drop down menu: options 1, 2, 3 and 4

However for the first drop down menu, if you choose the number then that number cannot be selected again on the second drop down menu. So if i pick 4 on the first drop down. then only 1, 2, and 3 should show up on the second drop down OR if you pick 4 on the second drop down it gives you an error saying you selected that value.

Here is the complicated part that I cannot figure out.

I want each drop down menus on two different pages and not on the same page. So after you select the submit button on the first drop down it should go to another page with the second drop down.. Has anyone seen this before. if you can give me some tips or show me how its done or even a webpage that has already implemented this i would appreciate it.

Thank you!

Hello all. I need desperate help with this. The code below is two drop down menus where if you pick one of the values in the first drop down menu and pick the same exact value in the second drop down menu then it will give you an error stating that you can only select that value once. Example: if i choose T2 on the first drop down menu and select T2 on the second drop down it will print an error stating that you need to select another option.

Here is where I need help. I want to have one of the drop down menus on one page named p1.html and have the other drop down on another page called p2.html. I need a solution on how to pass the information from the first drop down on p1.html to p2.html so it will know which was chosen on p1.html can anyone please help?

Here is the code

[code=html]
<html>
<title> hi </title>

<head>
</head>
<body>

First Choice: <select name=”ThursAM_First” size=”1″ id=”ThursAM_First”
onchange=”return no_dupes(this,ThursAM_Second)”>
<option value=”” selected>• choose •</option>
<option value=””></option>
<option value=”T1″>T1</option>
<option value=”T2″>T2</option>
<option value=”T3″>T3</option>
<option value=”T4″>T4</option>
</select>

Second Choice: <select name=”ThursAM_Second” size=”1″ id=”ThursAM_Second”
onchange=”return no_dupes(this,ThursAM_First)”>
<option value=”” selected>• choose •</option>
<option value=””></option>
<option value=”T1″>T1</option>
<option value=”T2″>T2</option>
<option value=”T3″>T3</option>
<option value=”T4″>T4</option>
</select>

</html>

<script type=”text/javascript” src=”new.js”></script>

[/code]

Here is the javascript code that will give you an error if you select the same value twice…

[CODE]

function no_dupes(oSelect, oSelect2)
{
var selval = oSelect.options[oSelect.selectedIndex].v…
var opt, i = 0;
while (opt = oSelect2.options[i++])
if (opt.value && !opt.defaultSelected && (opt.selected && opt.value == selval))
{
alert(“n Sorry, you already choose this point value for round 1. Please select another!nThanks.”);
oSelect.selectedIndex = 0;
return false;
}
}
[/CODE]

Thank you all!!!

Please help me. I have 2 web pages. first webpage has a drop down with 4 options. second webpage has another dropdown with 4 options, however, you get an error message if you choose the same option as the first drop down.

This all works perfect if both drop down menus are on one page, however, I need it to be on separate pages so i need a cookie to hold what option i picked for the first drop down so the second drop down knows to give me that error if i choose the same option.. Can someone help me with the cookie part. Here is my code…

dropdown1.html (first drop down menu)

[CODE]
<form name=”input” action=”start2.html” method=”get”>
First Choice: <select name=”ThursAM_First” size=”1″ id=”ThursAM_First”
onchange=”return no_dupes(this,start2.html.ThursAM_Second…
<option value=”” selected>• choose •</option>
<option value=””></option>
<option value=”T1″>T1</option>
<option value=”T2″>T2</option>
<option value=”T3″>T3</option>
<option value=”T4″>T4</option>
</select>
<input type=”submit” value=”Submit” />
</form>

<script language=”javascript” src=”script.js”></script>
[/CODE]

______________________________________…
dropdown2.html (second drop down menu)

[CODE]
<form>
Second Choice: <select name=”ThursAM_Second” size=”1″ id=”ThursAM_Second”
onchange=”return no_dupes(this,ThursAM_First)”>
<option value=”” selected>• choose •</option>
<option value=””></option>
<option value=”T1″>T1</option>
<option value=”T2″>T2</option>
<option value=”T3″>T3</option>
<option value=”T4″>T4</option>
</select>
</form>

<script language=”javascript” src=”script.js”></script>
[/CODE]


_________________________

scrip.js (here is my .js file with all my javafunctions)

[CODE]
function no_dupes(oSelect)
{
var f = document.forms[0];
if (f.ThursAM_First.value == f.ThursAM_Second.value)
{
alert(“n Sorry, you already choose this point value for round 1. Please select another!nThanks.”);
oSelect.selectedIndex = 0;
return false;
}
}

[/CODE]

Thank you!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangMar 28.2010 — The selection is naturally passed to the next page by the form. Read the query in the second page.
×

Success!

Help @connollyc4 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.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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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