fredowinz23 Posted August 24, 2008 Share Posted August 24, 2008 hi there... please give me the script how to disable the textbox if the check box is not check yet... please... i really need your help for our thesis Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted August 24, 2008 Share Posted August 24, 2008 I think you want javascript for this. Just google it. Were not here to hand out free scripts :-\ Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted August 25, 2008 Share Posted August 25, 2008 Something like this? <input id='myCheckBox' type='checkbox' onclick='tehFunc();' /> <br /> <input id='myTextArea' type='text' disabled /> <script> function tehFunc() { document.getElementById("myTextArea").disabled = false; } </script> Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 25, 2008 Share Posted August 25, 2008 That script is not complete. It will enable the text field when the checkbox is first checked, but will not disable the field when it is unchecked. I would also add functionality to clear the value in the text field when the checkbox is unchecked. Try this: <html> <head> <script type="text/javascript"> function enableText(checkBool, textID) { textFldObj = document.getElementById(textID); //Disable the text field textFldObj.disabled = !checkBool; //Clear value in the text field if (!checkBool) { textFldObj.value = ''; } } </script> </head> <body> <input id="myCheckBox" type="checkbox" onclick="enableText(this.checked, 'myTextArea');" /> <br /> <input id="myTextArea" type="text" disabled="disabled" /> </body> </html> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted August 25, 2008 Share Posted August 25, 2008 That script is not complete. It will enable the text field when the checkbox is first checked, but will not disable the field when it is unchecked. I would also add functionality to clear the value in the text field when the checkbox is unchecked. Try this: <html> <head> <script type="text/javascript"> function enableText(checkBool, textID) { textFldObj = document.getElementById(textID); //Disable the text field textFldObj.disabled = !checkBool; //Clear value in the text field if (!checkBool) { textFldObj.value = ''; } } </script> </head> <body> <input id="myCheckBox" type="checkbox" onclick="enableText(this.checked, 'myTextArea');" /> <br /> <input id="myTextArea" type="text" disabled="disabled" /> </body> </html> Good call. Quote Link to comment Share on other sites More sharing options...
smithveg Posted November 7, 2008 Share Posted November 7, 2008 Thanks for the code. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.