/    Sign up×
Community /Pin to ProfileBookmark

Enabling/Disabling form field

How do I enable a form field depending on if a certain radio is checked? I have a form that asks that user for their purpose in writing. The form gives them three options for their purpose – General Information, Contact Staff Member, and Website Issue. Below the radio buttons I have a drop down select box that I want to be enabled ONLY if the user selected the “Contact Staff Member” radio above, so it should be disabled to begin with. How do I do this?

Here is my form that I want to do this with [url]http://calvary.spencer-designs.com/contact/[/url]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@thambaJun 17.2007 — Hi, This should help. Try it.

<html>

<head>

<script type="text/javascript">

function enable(){

if(document.dform.rad[1].checked){

document.dform.sel.disabled=false;

}else{

document.dform.sel.disabled=true;

}

}

</script>

</head>

<body>

<form name="dform">

<input type="radio" name="rad" value="1" onclick="enable()">

<input type="radio" name="rad" value="2" onclick="enable()">

<input type="radio" name="rad" value="3" onclick="enable()">

<select name="sel" DISABLED>

<option value="1">a</option>

<option value="2">b</option>

<option value="3">c</option>

</select>

</form>

</body>

</html>
Copy linkTweet thisAlerts:
@novemberGreyauthorJun 18.2007 — I couldn't get it to work...
Copy linkTweet thisAlerts:
@JMRKERJun 18.2007 — Works fine for me using FF, both post and site.

What browser are you using?
Copy linkTweet thisAlerts:
@novemberGreyauthorJun 18.2007 — nevermind it works...I just typed in something wrong, thankyou for your help!
×

Success!

Help @novemberGrey 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.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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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