Check checkbox in an asax page through javacsript

Posted by Khushi on Stack Overflow See other posts from Stack Overflow or by Khushi
Published on 2009-09-16T14:14:57Z Indexed on 2010/05/15 11:04 UTC
Read the original article Hit count: 220

Filed under:
|

I have a default page which loads different controls on pageload according to the querystring. I have a control which creates checkbox list (inside div_A) on load and get checkbox checked through database, then i click Continue, div_A get invisible with all the checked checkbox id in hidden field and div_B is visible true.

On Go Back click, div_B is visible false and div_A get visible true and following javascript is fired to check the selected checkbox, but it does not work

Javascript :
function goBack()
    {  
        var SIds = document.getElementById("<%=hdv_Data.ClientID %>").value;              // hdv_Data is the hidden field
        var Ids_Arr = new Array();
        Ids_Arr = SIds.split(',');
        for (j = 0; j < Ids_Arr.length; j++)
        {
            if(Ids_Arr[j] != 0)
            {
                alert(Ids_Arr[j]); // works till here, gets correct values in array
                var chk = document.getElementById(Ids_Arr[j]); 
                alert(chk);
                chk.checked = true;
             } 
        }
    }

© Stack Overflow or respective owner

Related posts about checkbox

Related posts about JavaScript