View Full Version : Disabling a form item
darkannie
04-23-2003, 11:39 PM
i didn't know which part of the board to ask this so i chose general. i was wanting to know how to disable a form item unless someone clicks on a checkbox? the item i was to disable is a textbox. i want to have a question that a person will use a checkbox to answer and if he/she doesn't check it, then the textarea will remain disabled.
cg9com
04-24-2003, 02:02 AM
Hi,
This can be best accomplished with javascript.
I'll move you to that forum. :)
cheesebagpipe
04-24-2003, 02:17 AM
<html>
<head>
<title>untitled</title>
</head>
<body>
<script type="text/javascript" language="javascript">
function enableDisable(field) {
field.disabled = !field.disabled;
field.value = '';
if (!field.disabled) field.focus();
}
</script>
<form>
<input type="checkbox" onclick="enableDisable(stuff)">
<input type="text" name="stuff" disabled="disabled">
</form>
</body>
</html>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.