$(".agree-condition").text("I agree to receive information from ISBR Business School."); var InstituteProgrammeObj = { "88697": ["88791", "88790"], "87529": ["88775", "88776", "88777"], "87528": ["88769", "88770", "88771", "88772", "88773", "88774"], "87530": ["88778", "88779", "88780", "88781", "88782", "88785", "88784"], "87531": ["88786","88787", "88789", "88788"] }; $('#UniversityId').change(function (event) { var Institute = event.target.value for (var key in InstituteProgrammeObj) { if (InstituteProgrammeObj.hasOwnProperty(Institute)) { $('#CourseId option').not(':eq(0)').each(function (i, e) { if (InstituteProgrammeObj[Institute].indexOf(e.value) == -1) { $(e).prop("disabled", true).attr("disabled", "disabled").hide(); } else { $(e).prop("disabled", false).removeAttr("disabled").show(); } }); } else { $('#CourseId option').not(':eq(0)').prop("disabled", true).attr("disabled", "disabled").hide(); } } $('#CourseId').val($('#CourseId option:eq(0)').val()); }); $('#CourseId option').not(':eq(0)').prop("disabled", true).attr("disabled", "disabled").hide();