/    Sign up×
Community /Pin to ProfileBookmark

disabling select with check boxes

ei im new to javascript can anyone help me with this code… i hav 3 radio buttons after each radio button is another input type… d input types were all disabled and i only want to enable them if their corresponding radio button is selected but it doesnt seem to work
here is my code:

<script language = “javascript”>

function enable()
{
if(document.create.mwfTime.disabled == “checked”)
}

function disable()
{
document.create.mwfTime.disabled = true;
}

<form name = “test”>
<input type = “radio” name = “choice” value = “ex1”> example1
<select name = “mwfTime” disabled = “true” >
<option selected> Select choices</option>
<option> one</option>
<option> two</option>
</select>

<input type = “radio” name = “choice” value = “ex2”> example2 &nbsp
<select name = “TTHTime” disabled = “true” = “select2”>
<option selected> Select choices</option>
<option> three </option>
<option> four</option>
</select>
</form>

im really looking forward to ur response thanks

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangDec 09.2005 — &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;Select enable&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

&lt;script type="text/javascript"&gt;
function enable(obj, sel) {
var f=document.test;
f.elements[obj.value].disabled="";
f.elements[sel].disabled=true;
}
&lt;/script&gt;

&lt;style type="text/css"&gt;
/* cascading style sheet */

&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;form name = "test"&gt;
&lt;fieldset&gt;
&lt;label&gt;&lt;input type = "radio" name = "choice" value = "mwfTime" onclick="enable(this, 'TTHTime');"&gt;example1 &lt;/label&gt;
&lt;select name = "mwfTime" disabled&gt;
&lt;option selected&gt; Select choices&lt;/option&gt;
&lt;option&gt; one&lt;/option&gt;
&lt;option&gt; two&lt;/option&gt;
&lt;/select&gt;

&lt;label&gt;&lt;input type = "radio" name = "choice" value = "TTHTime" onclick="enable(this, 'mwfTime');"&gt;example2 &lt;/label&gt;
&lt;select name = "TTHTime" disabled&gt;
&lt;option selected&gt; Select choices&lt;/option&gt;
&lt;option&gt; three &lt;/option&gt;
&lt;option&gt; four&lt;/option&gt;
&lt;/select&gt;
&lt;/fieldset&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @JackOfBlades 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.3,
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,
)...