I’m experiencing issues with IE9 which is not performing the actions I need when clicking a button that was initially disabled, and re-enabled via javascript.
I have a form (built with perl CGI) which has several buttons. These are all disabled in the actual html, and are being enabled when the form is completely loaded. This is done to avoid users saving the page before it is fully loaded.
In all browsers the buttons appear disabled initially, and get enabled when the page is fully loaded. Also in IE.
Now these re-enabled buttons don’t do their work when clicked in IE (tested with IE 9), but they do work as expected in firefox and chrome.
The code for one of these buttons as it appears in the IE developer tools:
<input name="Event_Action" id="syncStream" type="submit" value="Create Sync Stream"/>
The code which creates the button initially disabled:
print $query->submit( -name=>'Event_Action', -value=>$btnCreateSyncStream, -disabled=>'disabled', -id=>'syncStream');
The buttons are being enabled via the onload event of the body tag:
<body onload="enableButtons()">
<form method="post" action="/cgi-bin/pdf/pdf.pl?&pdf_id=1071&release=at7.1.0&pdf_patch_rel_phase=b" enctype="application/x-www-form-urlencoded" onsubmit="return validatePatchNr()" name="MYFORM">
The javascript function enableButtons:
function enableButtons()
{
var buttons = document.getElementsByName("Event_Action");
for (i=0;i<buttons.length;i++)
{
buttons[i].disabled=false;
}
}
Now, when one of these re-enabled buttons is being used, IE seems to reload the page, but the actual action linked to the button is not being executed.
The same page in Chrome and Firefox works correctly. Both of these browsers execute the correct action.
I supsect that not every field on the form is being submitted which causes the Perl script not to recognize the action that is requested, but I’m not sure of that yet.
I tried debugging the issue with the dev tools in IE, but those are not really easy to work with if you’re used to firebug.
Anyone has any idea what might be going wrong here? I might be missing something obvious.
Well did you try to use different name of each button ? Usually some browser do not submit name value pair of each button, but some browser does. I Guess you should change the name of each button to be unique and use a hidden field to determine the Action to perform rather than button VALUE.