That works fine except that I'm using an ASP:Button with code behind it.
That's why the funny name.
Any thoughts on getting this to work with ASP controls?
TIA - Jeff.
Ahh, you are correct--wow, that's really annoying. I tend to use HTML controls
wherever possible, so I've honestly never ran across this.
Okay, here's what I came up with. This is more of a snafu battle between
FF and IE--out of all of them, Safari seems the most forgiving. Hah. I tested
in FF2, FF7, and Safari. So far, so good.
Anyway, I extracted this into a method, but I'll show both inline and the
method.
Html (all of it):
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function toggleButton(checkedValue)
{
// You can remove the alerts; they were for testing!
var button = document.getElementById('btnToCheckOut');
alert("currently disabled: " + button.disabled);
alert("checked value: " + checkedValue.toString());
button.disabled = checkedValue;
alert("now disabled: " + button.disabled);
return true;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="checkbox"
onclick="javascript:toggleButton(!this.checked);" />Accept?
<asp:Button runat="server" ID="btnToCheckOut" Enabled="false" Text="Checkout"
/>
</div>
</form>
</body>
</html>
and here's inline without the helper method:
<input type="checkbox"
onclick="javascript: var button = document.getElementById('btnToCheckOut');
button.disabled = !this.checked; return true;" />
That's modifying that <asp:Button> object. From what I can tell, IE doesn't
care, but FireFox wants the attribute assignment separated out from the getElementById
call. I'm sure Google could tell why... perhaps it has something to do with
the page loading order of how the controls hit the page.
HTH!
-dl
--
David R. Longnecker
http://blog.tiredstudent.com
> That works fine except that I'm using an ASP:Button with code behind
> it. That's why the funny name.
[quoted text clipped - 40 lines]
>>>
>>> TIA - Jeff.