/    Sign up×
Community /Pin to ProfileBookmark

Disable button

I am creating a simple terms and conditions section on my site.

I will have two radio buttons, i accept and i decline. by default i decline is selected and hence the Next button is disabled. when the user selects i accept, the Next button should become re-enabled.

could someone please help me with this code, i believe in need javascript for this.

thanks

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@fredmvJun 10.2005 — In the radio:onclick="document.getElementById('next').disabled=false"In the "Next" button:id="next"You may also want to disable the "Next" button via JavaScript so that non-JavaScript users won't be stuck with a disabled button.
Copy linkTweet thisAlerts:
@CharlesJun 10.2005 — <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>

<style type="text/css">
<!--
fieldset {padding:1ex; width:10em}
label {display:block; text-align:left}
input {margin-right:1ex}
button {display:block; margin:1ex auto}
-->
</style>

</head>
<body onload="document.forms[0].go.disabled = true">
<form action="http://www.bettiepage.com/">
<fieldset>
<legend>Just how old are you?</legend>
<label><input name="age" onclick="this.form.go.disabled = this.checked" type="radio">Under 21</label>
<label><input name="age" onclick="this.form.go.disabled = !this.checked" type="radio">Over 21</label>
<button name="go" type="submit">Submit</button>
</fieldset>
</form>
</body>
</html>
Copy linkTweet thisAlerts:
@ag201authorJun 10.2005 — thanks a lot. you are a genius.
Copy linkTweet thisAlerts:
@ag201authorJun 10.2005 — why are all the radio buttons selectable, everytime i select something else, the first selection doesnt go away. please help. i think i am absolutely dumb.
Copy linkTweet thisAlerts:
@ag201authorJun 10.2005 — i know whats wrong. the name attribute was diffferent, it has to be the same for both radio buttons. thanks to all though.
×

Success!

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

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.12,
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,
)...