I have an HTML form with two disabled checkboxes and and image with an onclick event that needs to show a popup and enable the checkboxes:
<input id="chk1" type="checkbox" disabled="disabled" />
<input id="chk2" type="checkbox" disabled="disabled" />
<img src="..." onclick="window.open('...'); document.getElementById('chk1').disabled=false;document.getElementById('chk2').disabled=false" />
except it doesn't work. The popup window opens, but the checkboxes never enable.
Instead of disabled=false I've tried removeAttribute("disabled") with no luck. I also placed the window.open as the last statement in the onclick with no change.
jQuery is not in this project (yet) so I can't use it. What am I doing wrong?
Edit:
When I posted this, I failed to disclose the input tags are being rendered by ASP.NET. Through testing we've discovered there's a difference between using <asp:CheckBox /> and <input type="checkbox" runat="server" /> that affects how the disabled property behaves in IE and FF.
I've been under the impression that the final output would be the same, but apparently not, though I haven't been able to spot the difference. The rendered code as represented above works in FF but not IE when using an CheckBox object, but works in both when using an HtmlInputCheckBox object.
(I should also point out that the getElementById calls are actually using the ASP.NET ClientID property for the respective elements.)
My question now, then, is why is this the case? Why does the enable/disable functionality work in both IE and FF when using a HtmlInputCheckBox object but not for a CheckBox object?
<asp:CheckBox />and disable it on the server, the<span>that wraps it is also marked as disabled. IE has trouble with this while FF & Chrome ignore it. The only thing you need to do ischeckbox.parentNode.removeAttribute('disabled');