/    Sign up×
Community /Pin to ProfileBookmark

how to activate textfield once checkbox is checked..

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

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@CharlesMay 04.2007 — 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>
×

Success!

Help @recher spread the word by sharing this article on Twitter...

Tweet This
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...