I'm trying to turn textbox enable and disable depends on checked checkbox with java script, is there anyway to do this?
here is my code
<script type="text/javascript">
function ed1(bEnable, textBoxID, textBoxID2) {
document.getElementById("<%= textBoxID.ClientID %>").disabled = !bEnable
document.getElementById("<%= textBoxID2.ClientID %>").disabled = !bEnable
}
</script>
here is checkbox and text box
<asp:CheckBox ID="CH0" runat="server" Font-Names="Tahoma" onclick="ed1(this.checked, 'TB1', 'TB2');"
Font-Size="X-Small" Style="font-size: 12px; right: 20px; color: #006699;
font-family: Tahoma; position: absolute; top: 25px; width: 80px;"
/>
<asp:TextBox ID="TB0" runat="server" EnableViewState="False" Height="12px" MaxLength="2"
Style="font-size: 11px; right: 110px; vertical-align: middle; color: #0099ff; font-family: tahoma;
position: absolute; top: 25px; text-align: left; width: 15px; " Enabled="false"
Wrap="False" ValidationGroup="1234567890"></asp:TextBox>
<asp:TextBox ID="TB1" runat="server" EnableViewState="False" Height="12px" MaxLength="2"
Style="font-size: 11px; right: 140px; vertical-align: middle; color: #0099ff; font-family: tahoma;
position: absolute; top: 25px; text-align: left; width: 15px; " Enabled="false"
Wrap="False" ValidationGroup="1234567890"></asp:TextBox>
it won't work as asp doesn't undrestand what textBoxID means! (it has been declared on javascript!)
I'm getting following error:
BC30451: 'textBoxID' is not declared. It may be inaccessible due to its protection level.
if I put the actual IDs instead of textBoxID2 it will works great but as I have many check box and many text box to enable and disable making countless javascript doesn't seems a good idea!
let me know if this can be solvable and thanks in advance