jeudi 10 novembre 2016

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 my "All Course" option is checked i have to check remaining all options in dropdown and vice versa and i have to update my textarea accordingly.when I check "All Course" its working fine and my texarea is updated with "All Course" but if i uncheck its not working.

Aucun commentaire:

Enregistrer un commentaire