Monday, October 11, 2010

Enable and disable textbox when checked the checkbox

Here code show how enable and disble textbox when user checked the textbox.
code disble the row which contain the textbox.you can also take only checkbox
to enable and disble not neccessary to disble row.

function showHide()
{

var chkSignature = document.getElementById('ctl00_ContentPlaceHolder1_tabContainer_pnl_chkSign');
var trsign = document.getElementById('ctl00_ContentPlaceHolder1_tabContainer_pnl_trsign');
if(chkSignature.checked)
{
if(trsign != null)
{
trsign.style.display = '';
}
}
else
{
if(trsign != null)
{
trsign.style.display = 'none';
}
}
}

<tr>
<td style="height: 22px; width: 180px;">
</td>
<td align="left" colspan="3" style="height: 22px; text-align: left">
<asp:CheckBox ID="chkSignature" runat="server" Text="Show Signature" onclick="showHide()"/>
</td>
</tr>
<tr id="trsign" runat="server" style="display:none">
<td style="height: 22px; width: 180px;">
</td>
<td align="left" colspan="3" style="height: 22px; text-align: left">
<asp:TextBox ID="txtSignature" runat="server" Width="350px" TextMode="MultiLine" ></asp:TextBox>
</td>
</tr>

Thanks & Regards
Santosh

Thanks & Regards
Santosh

1 comment:

  1. This is a nice article..
    Its easy to understand ..
    And this article is using to learn something about it..

    c#, dot.net, php tutorial, Ms sql server

    Thanks a lot..!
    ri80

    ReplyDelete