Click to See Complete Forum and Search --> : how to activate textfield once checkbox is checked..


recher
05-04-2007, 05:03 AM
hi everyone, i'm new here!

i have this situation. i have a checkbox with a disabled text field beside it. and i want the text field to be active once my checkbox is checked so i can put something on my textfield. can i do that using html or i need to have a javascript?

thanks in advance!

regards,
recher

Charles
05-04-2007, 05:34 AM
You'll need to do this with JavaScript but you have to be careful not to ruin things for those of us who do not use JavaScript. You have to disable the TEXTAREA with JavaScript, not with HTML otherwise it will never get abled. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">

<script type="text/javascript">
onload = function () {
document.forms[0].foo.disabled = true;
}
</script>

<form action="some-script.pl">
<fieldset>
<input onclick="this.form.foo.disabled = !this.checked" type="checkbox">
<textarea name="foo"></textarea>
</fieldset>
</form>