Thursday, 25 July 2013

ShowHide div on RadioButton Click in javascript

<script language="javascript" type="text/javascript">
    function ShowDiv()
    {      
        if (document.getElementById('<%=rbtn_CourseWise.ClientID %>').checked == true)
        {          
            document.getElementById('<%=div_CourseWise.ClientID %>').style.visibility = "visible";
        }
    }
    function HideDiv()
    {
        if (document.getElementById('<%=rbtn_Complete.ClientID %>').checked == true)
         {
            document.getElementById('<%=div_CourseWise.ClientID %>').style.visibility = "hidden";
        }
    }  
 </script>



<tr valign="top">

<td width="40%">
<asp:RadioButton ID="rbtn_CourseWise" runat="server" Text="Coursewise Fee Reg." style="padding-left:13px;font-family:Verdana;font-size:11px" GroupName="Reg"/>
<asp:RadioButton ID="rbtn_Complete" runat="server" Text="Complete Fee Register" style="padding-left:13px;font-family:Verdana;font-size:11px" GroupName="Reg" Checked="true"/>
</td>

<td width="60%">
<div style="width:100%;visibility:hidden" id="div_CourseWise" runat="server">
<table width="100%">
<tr>
<td width="30%">
<asp:Label ID="lbl_Course" runat="server" Text="Course" CssClass="Details" style="padding-left:10px"></asp:Label>
</td>
</tr>
</table>
</div>
</td>
</tr>


on page_load

rbtn_CourseWise.Attributes.Add("onclick", "javascript:ShowDiv('" + rbtn_CourseWise.ClientID + "')");
rbtn_Complete.Attributes.Add("onclick", "javascript:HideDiv('" + rbtn_Complete.ClientID + "')");  

No comments:

Post a Comment