I am facing what initially seemed like a simple javascript issue, but now I am becoming frustrated trying to solve it.
The problem I encountered was with a slow-loading page where users could click the submit button and then another button while waiting for the page to load, causing complications. To address this, I attempted to display a "please wait" message and disable the submit button upon click. Below is the function I am using. Since I am working with asp.net 3.5, there is a name mangling issue, so I am using getElementByName and scanning for the appropriate items (not ideal, but it seems to function). However, when I execute this function, the button becomes disabled, but the server is not called. I checked in Firefox and did not see any errors in Firebug, but when I set a breakpoint on the server, it was evident that the server was not being called. I even tried returning true in case there was expected output, but it did not help. When I commented out the content of 'processing(){ // stuff }', the page worked fine, so something in that function is causing the issue.
function processing() {
var pleaseWaitID = "lblPleaseWait";
var submitBtnName = "btnSubmit";
var submitControl = document.getElementsByTagName('input');
var pleaseWaitlbls = document.getElementsByName(pleaseWaitID);
for (pleaseWait in pleaseWaitlbls) {
if (pleaseWaitlbls[pleaseWait].style != null) {
pleaseWaitlbls[pleaseWait].style.visibility="visible";
}
}
for (submitButton in submitControl) {
if (submitControl[submitButton].name != null) {
if (submitControl[submitButton].name.search(submitBtnName) != -1) {
submitControl[submitButton].disabled = "disabled";
}
}
}
return true;
}
.....
asp:Button ID="btnSubmit" name="btnSubmit" SkinID="MainAction" runat="server" Text="Submit" OnClientClick = "javascript:processing();"
OnClick="btnSubmit_Click" meta:resourcekey="btnSubmitResource1"
Any suggestions on what could be going wrong here?
Thank you for your attention.