我有三个组合框:如何禁用使用Javascript在另一个组合框中选择的组合框的值?
每个组合框具有以下值来选择:
组合框1:
- 英语
- 法国
- 西班牙
- 意大利
组合框2:
- 英语
- 法国
- 西班牙
- 意大利
组合框3:
- 英语
- 法国
- 西班牙
- 意大利
当值组合框1选择让我们说英语,那么这个值是在组合框2 & 3都被禁用。我想在JavaScript中做到这一点。可以任何身体帮助。我想禁用此值不删除它。
在此先感谢。
编辑
我尝试这样做:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function selectedLanguage(lang,comboxbox_id){
console.log(comboxbox_id);
var langSelected = lang.options[lang.selectedIndex].value;
console.log(langSelected);
if(comboxbox_id === 'language1'){
if(langSelected === 1){
//do nothing
document.getElementById('language2').style.disabled = true;
}else if(langSelected === 2){
}
}else if(comboxbox_id === 'language2'){
if(langSelected === 1){
//do nothing
}else if(langSelected === 2){
}
}
}
</script>
</head>
<body>
<select name="language1" id="language1" onchange="selectedLanguage(this,this.id)">
<option value="1">French</option>
<option value="2">English US</option>
<option value="3">Greek</option>
<option value="4">Swedish</option>
</select>
<select name="language2" id="language2" onchange="selectedLanguage(this,this.id)">
<option value="1">French</option>
<option value="2">English US</option>
<option value="3">Greek</option>
<option value="4">Swedish</option>
</select>
</body>
</html>
到目前为止您尝试过什么? – 2014-09-23 14:41:09
@AlexChar我编辑了这个问题。请看看我的尝试。 – k00989 2014-09-25 09:20:09