/    Sign up×
Community /Pin to ProfileBookmark

To Do With JavaScript Events (I think)

Can you tell me (or direct me to something that explains how to do EXACTLY what I am trying to do) how I can make a form with the radio buttons “Yes” and “No” and have a text field beneath it enable or disable (you know, turn grey and unuseable), based on which value was checked. And please note: This change should take affect immediately without having to reload the page.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJun 05.2006 — [code=html]<form action="">
<p>Yes: <input type="radio" name="R1" value="YES" checked onclick="
if(this.checked) this.form.T1.disabled = false;
return true;"> &nbsp;&nbsp;&nbsp;
No: <input type="radio" name="R1" value="NO" onclick="
if(this.checked) this.form.T1.disabled = true;
return true;"></p>
<p><input type="text" name="T1" size="20"></p>
</form>[/code]
Copy linkTweet thisAlerts:
@evenstar7139authorJun 05.2006 — [code=html]<form action="">
<p>Yes: <input type="radio" name="R1" value="YES" checked onclick="
if(this.checked) this.form.T1.disabled = false;
return true;"> &nbsp;&nbsp;&nbsp;
No: <input type="radio" name="R1" value="NO" onclick="
if(this.checked) this.form.T1.disabled = true;
return true;"></p>
<p><input type="text" name="T1" size="20"></p>
</form>[/code]
[/QUOTE]


Thank you so much. You're a sweetheart. God bless.
Copy linkTweet thisAlerts:
@phpnoviceJun 05.2006 — You're welcome.

Cheers.
Copy linkTweet thisAlerts:
@evenstar7139authorJun 09.2006 — Okay I need a little more help. How do I make it so the text box is disabled when the user first loads the page?
Copy linkTweet thisAlerts:
@phpnoviceJun 09.2006 — That isn't even a JavaScript question. That is only a change in HTML. Delete the [COLOR=Red]red[/COLOR] and insert the [COLOR=Blue]blue[/COLOR]:
&lt;form action=""&gt;
&lt;p&gt;Yes: &lt;input type="radio" name="R1" value="YES" [COLOR=Red]checked[/COLOR] onclick="
if(this.checked) this.form.T1.disabled = false;
return true;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;
No: &lt;input type="radio" name="R1" value="NO" [COLOR=Blue]checked[/COLOR] onclick="
if(this.checked) this.form.T1.disabled = true;
return true;"&gt;&lt;/p&gt;
&lt;p&gt;&lt;input type="text" name="T1" size="20" [COLOR=Blue]disabled[/COLOR]&gt;&lt;/p&gt;
&lt;/form&gt;
×

Success!

Help @evenstar7139 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.2,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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