/    Sign up×
Community /Pin to ProfileBookmark

radio button to control textbox enable or disable

I have five radio buttons(A-E), when click E radiobutton, then the textbox will enable. If click the others (A-D). The textbox will disable. How to do it?

Many thanks
Student

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@PittimannFeb 26.2005 — Hi!

<body onload="document.myform.text1.disabled=true">

<form name="myform" action="#">

<input type=radio name="rad" onclick="this.form.text1.disabled=true">

<input type=radio name="rad" onclick="this.form.text1.disabled=true">

<input type=radio name="rad" onclick="this.form.text1.disabled=true">

<input type=radio name="rad" onclick="this.form.text1.disabled=true">

<input type=radio name="rad" onclick="this.form.text1.disabled=false;this.form.text1.focus()">

<input name="text1" value="">

</form>

</body>

Cheers - Pit
Copy linkTweet thisAlerts:
@fisher999authorFeb 26.2005 — Hi, Pittimann

How to clear the content (when the user click the E radiobutton and enter the content in textfield), then click the others radiobutton (A-D?)

Many thanks

Student
Copy linkTweet thisAlerts:
@PittimannFeb 26.2005 — Hi!

Example: <input type=radio name="rad" onclick="this.form.text1.disabled=true;this.form.text1.value='';">

Cheers - Pit
Copy linkTweet thisAlerts:
@fisher999authorFeb 27.2005 — I have two textboxs need to enable or disable by two radio buttons. So, I rewrite the onload coding. But cannot disable the textbox when the page on load. How to do it?



<body onload="document.myform.text1.text2.disabled=true">

<form name="myform" action="#">

<input type=radio name="rad" onclick="this.form.text1.disabled=true">

<input type=radio name="rad" onclick="this.form.text1.disabled=true">

<input type=radio name="rad" onclick="this.form.text1.disabled=true">

<input type=radio name="rad" onclick="this.form.text1.disabled=true">

<input type=radio name="rad" onclick="this.form.text1.disabled=false;this.form.text1.focus()">

<input name="text1" value="">

<br>

<br>

<input type=radio name="rad1" onclick="this.form.text2.disabled=true">

<input type=radio name="rad1" onclick="this.form.text2.disabled=true">

<input type=radio name="rad1" onclick="this.form.text2.disabled=true">

<input type=radio name="rad1" onclick="this.form.text2.disabled=true">

<input type=radio name="rad1" onclick="this.form.text2.disabled=false;this.form.text2.focus()">

<input name="text2" value="">

</form>

</body>

Many thanks

Student
Copy linkTweet thisAlerts:
@fisher999authorFeb 27.2005 — Anyone can teach me?

Many thanks

Student?
Copy linkTweet thisAlerts:
@fisher999authorFeb 28.2005 — Hi! Pittimann

I try you code and find not work:

<input type=radio name="rad" onclick="this.form.text1.disabled=true;this.form.text1.value='';">

Sorry, I am a beginner... How to solve it? I try many many times, please..

Thanks

Student ?
Copy linkTweet thisAlerts:
@PittimannFeb 28.2005 — Hi!

Try something like this:[code=php]<body onload="document.myform.text1.disabled=true;document.myform.text2.disabled=true">
<form name="myform" action="#">
<input type=radio name="rad" onclick="this.form.text1.disabled=true; this.form.text1.value='';">
<input type=radio name="rad" onclick="this.form.text1.disabled=true; this.form.text1.value='';">
<input type=radio name="rad" onclick="this.form.text1.disabled=true; this.form.text1.value='';">
<input type=radio name="rad" onclick="this.form.text1.disabled=true; this.form.text1.value='';">
<input type=radio name="rad" onclick="this.form.text1.disabled=false; this.form.text1.focus()">
<input name="text1" value="">
<br>
<br>
<input type=radio name="rad1" onclick="this.form.text2.disabled=true; this.form.text2.value='';">
<input type=radio name="rad1" onclick="this.form.text2.disabled=true; this.form.text2.value='';">
<input type=radio name="rad1" onclick="this.form.text2.disabled=true; this.form.text2.value='';">
<input type=radio name="rad1" onclick="this.form.text2.disabled=true; this.form.text2.value='';">
<input type=radio name="rad1" onclick="this.form.text2.disabled=false; this.form.text2.focus()">
<input name="text2" value="">
</form>
</body>[/code]
Cheers - Pit
×

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 5.15,
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,
)...