asp.net mvc - have to enable and disable my dropdown list when "All Course" is checked. multiselect dropdown validation -
function updatetextarea() { var allvals = []; $('#coursedropdown :checked').each(function () { if ($(this).val() == "all courses") { if($(this).attr('checked')) { $("input[type=checkbox][name='course-dropdown-list']").attr('checked', true); allvals.push($(this).val()); } else if($(this).val() != "all courses") { $("input[type=checkbox][name='course-dropdown-list']").attr('checked', false); $(this).val() == ""; allvals.push($(this).val()); } } else { allvals.push($(this).val()); } }); $('#course').val(allvals); }
when "all course" option checked have check remaining options in dropdown , vice versa , have update textarea accordingly.when check "all course" working fine , texarea updated "all course" if uncheck not working.
try this
$("#checkbox1").val("false"); function oncheckchange() { if ($("#checkbox1").is(':checked')) { $("#dropdown1").attr('disabled', 'disabled'); $("#checkbox1").val("true"); } else { $("#dropdown1").removeattr('disabled'); } } $("#checkbox1").click(oncheckchange).change(oncheckchange);
Comments
Post a Comment