/    Sign up×
Community /Pin to ProfileBookmark

Disabling drop downs based on another drop down…

Why isn’t this easier? I’m still a beginner with javascript and I must be missing something really obvious. I’m trying to get a script to work that if the third option is selected in one drop down, it automatically disables another drop down.

What am I missing? My error messages suggest that the vars a and b aren’t translating into the function. It can’t understand process.a.value.

(FYI, the form is named ‘process’). Thanks for any help!

[CODE]function openOption(a,b) {
var val = process.a.value;
if (val == 3) {
document.process.b.disabled = ‘true’;
} else {
document.process.b.disabled = ‘false’;
}
}[/CODE]

Then the html is:

[code=html]<select name=”option1type” onChange=”openOption(‘option1type’,’option1size’);”>
<option value=”0″>Not Used</option>
<option value=”1″>Single Line Text</option>
<option value=”2″>Lg Text Box</option>
<option value=”3″>Checkbox</option>
</select>

<select name=”option1size” >
<option value=”8″>Small</option>
<option value=”18″>Medium</option>
<option value=”30″>Large</option>
</select>[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangDec 11.2007 — &lt;select name="option1type" onchange="openOption(this.value,'option1size');"&gt;
function openOption(val,b) {
if (val == 3) {
document.process.elements[b].disabled = true;
} else {
document.process.elements[b].disabled = false;
}
}
Copy linkTweet thisAlerts:
@soarchristauthorDec 11.2007 — You [B]ROCK![/B] I appreciate your response... works perfectly.
×

Success!

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