Saturday, March 13, 2010

Hide and show dive from client side

Javascript function

function OtherWarnings(x,link,clientId)
{
 link.style.display='none';
  if(x=='0')
  {
   document.getElementById(clientId+"otherwrngsDiv").style.display = "block";
   document.getElementById(clientId+"act1").style.display = "block";
  }
  else
  {
   document.getElementById(clientId+"otherwrngsDiv").style.display = "none";
   document.getElementById(clientId+"act0").style.display = "block";
  }
 
 }
HTML Code

 a href="javascript:void(0)" onclick="OtherWarnings('0',this,'%= ClientID%>')" id="%= ClientID%>act0">show other warning labels:/a>
            a href="javascript:void(0)" onclick="OtherWarnings('1',this,'%= ClientID%>')" id="%= ClientID%>act1" style="display: none">hide other warning labels:/a>
            div id="%= ClientID%>otherwrngsDiv" style="display: none">
                asp:CheckBoxList ID="chkOtherWarnings" runat="server" RepeatColumns="4" RepeatDirection="Horizontal"
                    Width="540px" OnDataBound="chkWarnings_DataBound">
                /asp:CheckBoxList>
            /div>