Click to See Complete Forum and Search --> : changing the disabled property of a submit button?


adam
01-17-2003, 05:34 PM
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

khalidali63
01-17-2003, 06:08 PM
This will do it for you.

cheers

Khalid


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

<form name="form1">
<input type="radio" name="Quote" value="1" onclick="changeDisabled('form1','btnSubmit')" />
<input type="submit" name="btnSubmit" value="Next" disabled="true" />
</form>

adam
01-17-2003, 06:15 PM
That's great, it worked a treat.

Thanks,

Adam