[jQuery] both 'if' and 'else' blocks being executed

[jQuery] both 'if' and 'else' blocks being executed

Greetings,
I am experiencing some crazy stuff, at least crazy to me...
Both the 'if' and 'else' blocks (according to firebug) are being
executed in the following anonymous function:
<html>
<head>
<script language="javascript" type="text/javascript"
src="/usr/share/javascript/jquery/jquery.js"></script>
<script language="javascript" type="text/javascript">
$(function() {
add_billable_oncheck();
});
function add_billable_oncheck() {
var billable_hidden = $('#billable_hidden')[0];
var billable_checkbox = $('#billable_checkbox')[0];
if ((billable_hidden != null) &&
(billable_checkbox != null)) {
$(billable_checkbox).change(
function(event) {
// These are the blocks that both get executed on checkbox check
if (billable_checkbox.checked) {
billable_hidden.disabled = true;
} else {
billable_hidden.disabled = false;
}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}
);
}
}
</script>
</head>
<body>
<form>
<input id="billable_hidden" type="hidden" name="billable"
value="No" />
<input id="billable_checkbox" type="checkbox" name="billable"
value="Yes" />
</form>
</body>
</html>
Does anyone have any insight into this one?
If I add 'return;' statements at the end of the blocks, things work as
expected, however I wouldn't expect that I should have to do that.
Thanks for the help,
--
Matt Zagrabelny - mzagrabe@d.umn.edu - (218) 726 8844
University of Minnesota Duluth
Information Technology Systems & Services
PGP key 1024D/84E22DA2 2005-11-07
Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2
He is not a fool who gives up what he cannot keep to gain what he cannot
lose.
-Jim Elliot