Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
89
rated 0 times [  96] [ 7]  / answers: 1 / hits: 17761  / 14 Years ago, sat, april 3, 2010, 12:00:00

How to disable asp:TextBox on client-side click on HTML checkbox or server-side asp:CheckBox using JavaScript?



<script type=text/javascript language=javascript>
function enableTextbox() {
// ?
}
</script>

<table>
<tr>
<td>
<input id=checkTake onclick=enableTextbox title=Take? />
</td>
</tr>
<tr>
<td>
<asp:TextBox runat=server ID=txtCommission />
</td>
</tr>
</table>

More From » .net

 Answers
12
<script type=text/javascript language=javascript>
function enableTextbox(checkbox) {
document.getElementById('<%= txtCommission.ClientID %>').disabled = !document.getElementById(checkbox).checked;
}
</script>

<table>
<tr>
<asp:CheckBox runat=server ID=checkTake onclick=enableTextbox(this.id) Checked=true Text=Take? />
</tr>
<tr>
<td>
<asp:TextBox runat=server ID=txtCommission MaxLength=8 CssClass=right />
</td>
</tr>
</table>

[#97169] Wednesday, March 31, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
grayson

Total Points: 36
Total Questions: 113
Total Answers: 95

Location: Tonga
Member since Fri, Aug 21, 2020
4 Years ago
;