Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling Several buttons through Script 2

Status
Not open for further replies.

Mickbw

Programmer
Jul 9, 2001
84
US
I have several submit buttons with the same name:
Code:
<input name="Process" type="submit" value="Export To HRS" onClick="submitFunction(1);" >&nbsp;
<input name="Process" type="submit" value="Display in Excel" onClick="submitFunction(2);">&nbsp;
<input name="Process" type="submit" value="Report" onClick="submitFunction(3);" >

submitFunction() is the following code
Code:
function submitFunction(i) {
   if (i==1) 
   //document.frmOutstanding.action= "Export2Excel.cfm";
   {alert('This process will take several minutes and will commence after you click the OK button.  Do not browse off this page until Export Confirmation is Displayed.');
   document.frmOutstanding.action= "HRSExport.cfm";
   document.getElementById("Process").disabled="true";
   }

When a button is clicked only the first button names Process is disabled. Is there a way to make all the buttons disable?

Michael Brennan-White
New Hampshire Treasury Department
 
try

function submitFunction(i) {
if (i==1)
//document.frmOutstanding.action= "Export2Excel.cfm";
{alert('This process will take several minutes and will commence after you click the OK button. Do not browse off this page until Export Confirmation is Displayed.');
document.frmOutstanding.action= "HRSExport.cfm";
myButtons = document.getElementsByName("Process");
for (i=0;i<myButtons.length;i++){
myButtons[i.disabled="true";
}
}
 
Thanks! I finally realized mine wasn't working because I wasn't putting quotes around the word "true"!!!

:)
 

You don't need to use quotes around the word "true" - the disabled poperty is a boolean, and requires a boolean value. Using a string would be worse, IMHO.

Nevermoor's code is also missing a closing square bracket near the end, and a final closing brace. This:

Code:
myButtons[i.disabled="true";
    }
   }

should read like this, IMHO:

Code:
myButtons[i].disabled = true;
    }
  }
}

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top