Wednesday, 29 October 2014

ASP.NET CheckBoxList check and uncheck with jQuery

//

function SetFishingDay() {
                var txtval = $("#<%= txt_setday.ClientID %>").val();
                var $ctrls = $('#<%= chkdayoffishing.ClientID %>');
                var mm = '';
                //Uncheck all
                var selValuefalse = [1,2,3,4,5,6,7];              
                for (var i = 0; i < selValuefalse.length; i++) {
                    $ctrls.find('input:checkbox[value=' + selValuefalse[i] + ']').prop('checked', false);
                }

                //check selected
                var selValuetrue = [];
                for (var i = 0; i < txtval.length; i++) {
                    selValuetrue.push(txtval[i]);
                }
                var $ctrls = $('#<%= chkdayoffishing.ClientID %>');
                for (var i = 0; i < selValuetrue.length; i++) {
                    $ctrls.find('input:checkbox[value=' + selValuetrue[i] + ']').prop('checked', true);
                }

                return false;

            }

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...