/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Relation between two select with array

Hi to All,

I have 3 menus.

In the first menu I select an email adress.

According to the email selected, in the second menu appears a problem list with an option called “Free Text”

I would like that,
ONLY when a user choose email1 with the second option “Free Text”,
OR when a user choose email2 with the unique option of “Free Text”,
in the third menu appears the voice “Choose priority …” with the other two options: urgent, normal ..

With this code, now the goal is ok only for email1,
with email2 happens nothing … ?

Thanks a lot in advance !!!

<head>
//
var summary_db = new Object()
var prior_db = new Object()
summary_db[“email1″] = [{value:”Problems of 1 level, text:”Problems of 1 level”},
{value:”Problems of schedule”, text:”Problems of schedule”},
{value:”Free Text”, text:”Free Text”}];
summary_db[“email2″] = [{value:”Free Text”, text:”Free Text”}];
prior_db[“Problems of 1 level”] = [{value:”2 hours”, text:”2 hours”}];
prior_db[“Problems of schedule”] = [{value:”4 hours”, text:”4 hours”}];
prior_db[“Free Text”] = [{value:”Normal (5 days)”, text:”Normal (5 days)”},{value:”Urgent (1 day)”, text:”Urgent (1 day)”}];
//
function setIssue(chooser) {
var newElem;
var where = (navigator.appName == “Microsoft Internet Explorer”) ? -1 : null;
var Iss_Chooser = chooser.form.elements[“iss_sum”];
while (Iss_Chooser.options.length) {
Iss_Chooser.remove(0);
}
var choice = chooser.options[chooser.selectedIndex].value;
var db = summary_db[choice];
if (choice == “email1”) {
newElem = document.createElement(“option”);
newElem.text = “Choose an Issue …”;
newElem.value = “Choose Issue …”;
Iss_Chooser.add(newElem, where);
}
for (var i = 0; i < db.length; i++) {
newElem = document.createElement(“option”);
newElem.text = db[i].text;
newElem.value = db[i].value;
Iss_Chooser.add(newElem, where);
}
}
//
function setPriority(chooser) {
var newElem;
var where = (navigator.appName == “Microsoft Internet Explorer”) ? -1 : null;
var prChooser = chooser.form.elements[“priority”];
while (prChooser.options.length) {
prChooser.remove(0);
}
var choice = chooser.options[chooser.selectedIndex].value;
var db = prior_db[choice];
if (choice==”Free Text”) {
newElem = document.createElement(“option”);
newElem.text = “Choose priority …”;
newElem.value = “Choose priority …”;
prChooser.add(newElem, where);
}
for (var i = 0; i < db.length; i++) {
newElem = document.createElement(“option”);
newElem.text = db[i].text;
newElem.value = db[i].value;
prChooser.add(newElem, where);
}
}
//
</script>
</head>

<body>
<form method=”POST” webbot-onSubmit language=”JavaScript” name=”FrontPage_Form1″>

<select name=”mess” id=”mess” onchange=”setIssue(this)”>
<option value=”<%=objRS(“Mess”)%>” selected><%=objRS(“Mess”)%></option>
<option value=”email1″>Mail 1</option>
<option value=”email2″>Mail 2</option>
</select>

<select id=”iss_sum” name=”iss_sum” onchange=”setPriority(this)”>
<option value=”<%=objRS(“Summary”)%>” selected><%=objRS(“Summary”)%></option>
</select>

<select name=”priority” id=”priority”>
<option value=”<%=objRS(“Priority”)%>” selected><%=objRS(“Priority”)%></option>
</select>

</body>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@il_bettoauthorOct 29.2010 — I have solved the problem in this way ...

I put in red the new code added ? ?

<head>

//

var summary_db = new Object()

var prior_db = new Object()

summary_db["email1"] = [{value:"Problems of 1 level, text:"Problems of 1 level"},

{value:"Problems of schedule", text:"Problems of schedule"},

{value:"Free Text", text:"Free Text"}];

summary_db["email2"] = [{value:"Free Text", text:"Free Text"}];

prior_db["Problems of 1 level"] = [{value:"2 hours", text:"2 hours"}];

prior_db["Problems of schedule"] = [{value:"4 hours", text:"4 hours"}];

prior_db["Free Text"] = [{value:"Normal (5 days)", text:"Normal (5 days)"},{value:"Urgent (1 day)", text:"Urgent (1 day)"}];

//

function setIssue(chooser) {

var newElem;

var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;

var Iss_Chooser = chooser.form.elements["iss_sum"];

while (Iss_Chooser.options.length) {

Iss_Chooser.remove(0);

}

var choice = chooser.options[chooser.selectedIndex].value;

var db = summary_db[choice];

if (choice == "email1") {

newElem = document.createElement("option");

newElem.text = "Choose an Issue ...";

newElem.value = "Choose Issue ...";

Iss_Chooser.add(newElem, where);

}

for (var i = 0; i < db.length; i++) {

newElem = document.createElement("option");

newElem.text = db[i].text;

newElem.value = db[i].value;

Iss_Chooser.add(newElem, where);

}

}

//

function setPriority(chooser) {

var newElem;

var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;

var prChooser = chooser.form.elements["priority"];

while (prChooser.options.length) {

prChooser.remove(0);

}

var choice = chooser.options[chooser.selectedIndex].value;

var db = prior_db[choice];

if (choice=="Free Text") {

newElem = document.createElement("option");

newElem.text = "Choose priority ...";

newElem.value = "Choose priority ...";

prChooser.add(newElem, where);

}

for (var i = 0; i < db.length; i++) {

newElem = document.createElement("option");

newElem.text = db[i].text;

newElem.value = db[i].value;

prChooser.add(newElem, where);

}

}

//

[COLOR="Red"]function setJump(chooser) {

var choice = chooser.options[chooser.selectedIndex].value;

if (choice=="mail2") {

var newElem;

var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;

var jpChooser = chooser.form.elements["priority"];

while (jpChooser.options.length) {

jpChooser.remove(0);

}

newElem = document.createElement("option");

newElem.text = "Choose priority ...";

newElem.value = "Choose priority ...";

jpChooser.add(newElem, where);

newElem = document.createElement("option");

newElem.text = "Normal (5 days)";

newElem.value = "Normal (5 days)";

jpChooser.add(newElem, where);

newElem = document.createElement("option");

newElem.text = "Urgent (1 day)";

newElem.value = "Urgent (1 day)";

jpChooser.add(newElem, where);

}

} [/COLOR]
//

</script>

</head>



<body>

<form method="POST" webbot-onSubmit language="JavaScript" name="FrontPage_Form1">



<select name="mess" id="mess" onchange="setIssue(this);[COLOR="red"]setJump(this)[/COLOR]">

<option value="<%=objRS("Mess")%>" selected><%=objRS("Mess")%></option>

<option value="email1">Mail 1</option>

<option value="email2">Mail 2</option>

</select>





<select id="iss_sum" name="iss_sum" onchange="setPriority(this)">

<option value="<%=objRS("Summary")%>" selected><%=objRS("Summary")%></option>

</select>





<select name="priority" id="priority">

<option value="<%=objRS("Priority")%>" selected><%=objRS("Priority")%></option>

</select>



</body>
×

Success!

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