Forum Moderators: open
I want to disable and enable buttons on various parts of a web site. I have a function which takes two arguments, the form id/name and the button id/name, and attempts to enable/disable the button based on these arguments.
I cannot seem to get this to work when i pass arguments to the function, however it will work if i specify the form and button name within the function.
I have tried both the following ways and neither work
function submitEnable(formID, buttonID){
document.getElementById(formID).getElementById(buttonID).disabled=false;
} and...
function submitEnable(formName, buttonName){
document.[formName].[buttonName].disabled=false;
} Does anybody have any suggestions..?
Thanks
getElementById() is a method of the document object.
Try this...
function enableButton(ID,enable){ // enable must be true or false
var b = document.getElementById(ID);
if (b) b.disabled =!enable;
} Kaled.