/    Sign up×
Community /Pin to ProfileBookmark

changing the disabled property of a submit button?

Hi,

I have the following JavaScript function :

function changeDisabled(formname,elementname)
{
document.formname.elementname.disabled = false
}

and it’s referenced from my web page like so :

<form>
<input type=”radio” name=”Quote” value=”1″ onclick=”changeDisabled(this.form,Submit)” />
<input type=”submit” name=”Submit” value=”Next” disabled=”true” />
</form>

Now when the radio button is clicked, there will be more than one, I want the submit button to be enabled. For some reason this isn’t working at the moment. But then I don’t really know a lot about JavaScript, and I just cobbled this together from various places.

Anyone know how to do this for me?

Thanks,

Adam

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63Jan 18.2003 — This will do it for you.

cheers

Khalid

<i>
</i>&lt;body&gt;
&lt;script&gt;
function changeDisabled(formname,elementname){
var obj = eval('document.'+formname+'.'+elementname);
obj.disabled = false;
}
&lt;/script&gt;
and it's referenced from my web page like so :

&lt;form name="form1"&gt;
&lt;input type="radio" name="Quote" value="1" onclick="changeDisabled('form1','btnSubmit')" /&gt;
&lt;input type="submit" name="btnSubmit" value="Next" disabled="true" /&gt;
&lt;/form&gt;
Copy linkTweet thisAlerts:
@adamauthorJan 18.2003 — That's great, it worked a treat.

Thanks,

Adam
×

Success!

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