我想检查下拉菜单是否已禁用。如果是,我还有进一步的行动要做。据我说,一个禁用的下拉菜单返回一个值 -1 。任何人都可以告诉我任何其他方式在javascript中做到这一点。
以下是我的代码:
if(form["view.modeEnabled"].value == "true"){
if((form.outFlag.checked) && ((form.outMode.value == -1) || (form.outMode.value == 0))){
invalidOut = true;
}
if((form.outFlag.checked) && ((form.outMode.value == 1))){
if(form.outModele.value == -1 || form.outModele.value == 0){
invalidOut = true;
}
}
if((form.outFlag.checked) && ((form.outMode.value == 2))){
if(form.outModeleRes.value == -1 || form.outModeleRes.value == 0){
invalidOut = true;
}
}
if((form.outFlag.checked) && ((form.outMode.value == 3))){
if(form.outModeleRes.value == -1 || form.outModeleRes.value == 0 || form.outModele.value == -1 || form.outModele.value == 0 ){
invalidOut = true;
}
}
if((form.inFlag.checked) && ((form.inMode.value == -1)|| (form.inMode.value == 0))){
invalidIn = true;
}
if((form.inFlag.checked) && ((form.inMode.value == 1))){
if(form.inModele.value == -1 || form.inModele.value == 0){
invalidOut = true;
}
}
if((form.inFlag.checked) && ((form.inMode.value == 2))){
if(form.inModeleRes.value == -1 || form.inModeleRes.value == 0){
invalidOut = true;
}
}
if((form.inFlag.checked) && ((form.inMode.value == 3))){
if(form.inModeleRes.value == -1 || form.inModeleRes.value == 0 || form.inModele.value == -1 || form.inModele.value == 0 ){
invalidOut = true;
}
}
if((invalidOut == false) && (invalidIn == false)){
submitForm(form) ;
}else{
// alert('La sélection du mode est obligatoire pour HO IN / OUT création');
window.message="La sélection du mode est obligatoire pour HO IN / OUT création";
OuvrirFenetreModal('popupErrorCreate.jsp','popup','top=300,left=350,directories=no,width=300,height=80,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}
}else{
submitForm(form) ;
}