/    Sign up×
Community /Pin to ProfileBookmark

use radio button replace the checkbox?

Hi, I want to use radio button relpace the checkbox but can’t work. How to do it?

<form action=””>
<div>
<label><input type=”checkbox” onclick=”if (this.checked) {this.form.description.onfocus = function () {}; this.form.description.focus()} else {this.form.description.value = ”; this.form.description.onfocus = function () {this.blur()}}”>Other</label>
<label>Description<textarea name=”description” onfocus=”this.blur()”></textarea></label>
</div>
</form>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Feb 27.2005 — You question is no very clear.

Do you want to use a radio button instead of using a checkbox in the surrent code you have? What are the issues you are aving when you change it?

Eric
Copy linkTweet thisAlerts:
@fisher999authorFeb 27.2005 — Hi, I just want to use the radiobutton to enable/ disable the textarea. ?

thanks
Copy linkTweet thisAlerts:
@VladdyFeb 27.2005 — Using checkbox or radio button is not about what you want but what type of data you need to present.

Checkboxes are used for two option answers such as "Yes/No"
<i>
</i>&lt;label&gt;
&lt;input type="checkbox"
onchange="document.getElementById('textArea').disabled = !this.checked"
checked="checked" /&gt;
Enable Text Area
&lt;/label&gt;
&lt;textarea id="textArea"&gt;
text area text
&lt;/textarea&gt;

Radio buttons are used for questions with multiple choice questions (which can reduce to two "yes/no" options):
<i>
</i>&lt;fieldset&gt;
&lt;legend&gt;Text Area&lt;/legend&gt;
&lt;label&gt;
&lt;input type="radio"
name="textAreaControl"
onchange="document.getElementById('textArea').disabled = !this.checked"
checked="checked" /&gt;
Enable
&lt;/label&gt;
&lt;label&gt;
&lt;input type="radio"
name="textAreaControl"
onchange="document.getElementById('textArea').disabled = this.checked" /&gt;
Disable
&lt;/label&gt;
&lt;/fieldset&gt;
&lt;textarea id="textArea"&gt;
text area text
&lt;/textarea&gt;

For your application checkbox is easier to implement and easier to use. No reason to abuse both radio buttons and user by employing unnecessary controls.
×

Success!

Help @fisher999 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...