嗨,我写了一个小的 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
' 因此我得到了上述错误。