こんにちは、小さな JavaScript 関数を作成しましたが、次のようにエラーが発生します。"Options is Null or not an object"
これが私のコードです:
function ValidateMarks(sender, args) {
var ddlCategory = document.getElementById('ctl00_rightContainer_ContentTable2_ddlCategory').value;
var ddlDisabilityClass = document.getElementById('ctl00_rightContainer_ContentTable2_ddlDisabilityClass').value;
var GraduationPercntage = document.getElementById('ctl00_rightContainer_ContentTable2_txtGraduationPercntage').value;
var objCVValidateMarks = document.getElementById("ctl00_rightContainer_cvValidateMarks");
if ((ddlCategory.options[ddlCategory.selectedIndex].text == "-- Select Category --" || ddlCategory.options[ddlCategory.selectedIndex].text == "UR") && (ddlDisabilityClass.options[ddlDisabilityClass.selectedIndex].text == "No")) {
if (parseFloat(GraduationPercntage) < parseFloat('49.50')) {
objCVValidateMarks.errormessage = 'You are required 49.50% marks in B.Pharmacy to fulfill the eligibility.';
args.IsValid = false;
}
}
else {
if (parseFloat(GraduationPercntage) < parseFloat('44.50')) {
objCVValidateMarks.errormessage = 'You are required 44.50% marks in B.Pharmacy to fulfill the eligibility.';
args.IsValid = false;
}
}
}
ddlcategory の値を確認すると、選択した値が表示されますがddlCategory.selectedIndex
、値が ' undefined
' として表示されるため、上記のエラーが発生します。