Hi *,
I've got the following code, which should enable (or disable) a submit
button according to the state of a checkbox.
(Standard procedure in german web-shops: Users have to check a
checkbox "I accept the terms and conditions, blah, blah, ... before
they can finalize their order - a bit like a EULA.)
The code is working in FF, but in IE6 the changes to the button are
only shown after an additional mouseclick anywhere in the browser
window. (i.e. the user checks/unchecks the checkbox, nothing seems to
happen, when the user clicks anywhere else, the changes are applied/
made visible.)
Any ideas as to what I'm doing wrong?
Oh, and as you've probably guessed: this code is mostly copy/paste, as
I'm new to JS and MochiKit, so any suggestions for improvements are
welcome!
Regards
Puck
---------------- Java Script -------------------------------
var conn = MochiKit.Signal.connect;
function t_and_c_changed(event) {
var checked = filter(
itemgetter('checked'),
getElementsByTagAndClassName("input", null,
$('t_and_c'))
);
if (checked.length > 0) {
newButton = INPUT({'id':'submit_order', 'class':'add_to_cart',
'type':'submit'})
} else {
newButton = INPUT({'id':'submit_order', 'class':'add_to_cart',
'type':'submit', 'disabled':'disabled'})
}
swapDOM($('submit_order'), newButton);
}
function init_terms_and_conditions() {
var par = $('t_and_c')
var inputs = getElementsByTagAndClassName("input", null, par);
t_and_c_changed(null);
conn(inputs[0], 'onchange', t_and_c_changed);
}
conn(window, 'onload', init_terms_and_conditions);
--------------------- HTML ---------------------------
<form action="/cart/finalize_order" method="post">
...
<div class="description" id="t_and_c">Please
acknowledge our terms
and conditions and confirm your order.
<input type="checkbox" name="accept_terms"
value="accepted"
id="accept_terms_check"/> <label for="accept_terms"> I accept the
terms and conditions. </label>
</div>
...
<div class="bottomright">
<input disabled="disabled" type="submit"
class="add_to_cart"
id="submit_order" />
</div>
</form>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---