hi can any one please tell me how to disable textbox, if checkbox is checked and enable textbox if the checkbox is not checked
+1
A:
Are you using "plain" JavaScript or some library (jQuery, prototype, ...)?
Jan Hančič
2009-10-07 13:12:28
this should be a comment not an answer
jmein
2009-10-07 13:16:02
I know, but I can't comment yet :(
Jan Hančič
2009-10-07 13:18:02
at least not on other answers/questions that are not mine ...
Jan Hančič
2009-10-07 13:18:45
+5
A:
Put this in the checkbox:
onclick="document.getElementById('IdOfTheTextbox').disabled=this.checked;"
Guffa
2009-10-07 13:13:10
A:
Is pseudocode (not a lot of javascript experience):
OnCheckboxChanged(bool isChecked) {
textbox.Enabled = !isChecked;
}
Greg D
2009-10-07 13:13:43
A:
function disableControl(controlId)
{
document.getElementById(controlId).disabled = true;
}
James
2009-10-07 13:14:45
+1
A:
Using jQuery:
$("#checkbox").click(function(){
$("#textbox").disabled = $(this).is(":checked");
});
Marius
2009-10-07 13:14:52
+2
A:
<input type="text" id="textBox">
<input type="checkbox" id="checkBox" onclick="enableDisable(this.checked, 'textBox')">
<script language="javascript">
function enableDisable(bEnable, textBoxID)
{
document.getElementById(textBoxID).disabled = !bEnable
}
</script>
Kevin
2009-10-07 13:15:32