views:

61

answers:

1

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;
             } 
        }
    }
A: 

I wish it may help you im using this to hide and show some fields in a jsp, you may arrange it to fit your need.
- javascript

function showArea(){
var checkbox = document.getElementById('codcheckbox');
if(checkbox.value==true){
    var element = document.getElementById( 'dataFields' );
    if (element && element.style.display=='none'){
    element.style.display='block';
    }else{
    element.style.display='none';
    }
}
};
  • jsp form content...

    <tbody id="dataFields" style="display: none">
    <OTHER STUFF>
    </tbody>

Aktheus