Thursday, June 12, 2014

Checkbox Checked then disable multiple DropwownList

Checkbox Checked then disable multiple DropwownList
Form load   Enable/Disable

Two DropdownList Id:
ParentId-CycleFiler
*********************************chhtml Page****************************
<script type="text/javascript">
    $(document).ready(function () {
   
        $('input[data-target]').each(function () {
            enableDisabled(this);
        })

    });

    function enableDisabled(self){
        var get_target = $(self).attr('data-target').split('-');
        if($(self).is(':checked')){
            for(var i=0;i<get_target.length;i++){
                $('#'+get_target[i]).attr('disabled','disabled');
            }
        }
        else {
            for(var i=0;i<get_target.length;i++){
                $('#'+get_target[i]).removeAttr('disabled');
            }
        }
    }
</script>

  @Html.CheckBoxFor(c => c.IsParent, new { data_target = "ParentId-CycleFiler", onChange = "enableDisabled(this)" })
            @Html.CheckBoxFor(c => c.IsParent, new { data_target = "ParentId", onChange = "enableDisabled(this)" })
 ************************************************************



           

No comments:

Post a Comment