I am trying to make sure that if the checkbox on our page is checked, it will display a warning message notifying the user they selected to show their discharge history. If the user deselects the checkbox, he should show another window with a warning that they refuse to show their statement history. I am having trouble displaying warning boxes, even if the checkbox is checked / not checked. Here is my code.
HTML
<div class="myAccountCheckboxHolder" id="showCheckoutHistoryCheckbox">
<input tabindex="40" checked="checked" id="showCheckoutHistory" name="showCheckoutHistory" type="checkbox">
<label for="showCheckoutHistory" class="checkLabel">Show my checkout history</label>
</div>
Javascript
function validate() {
var checkoutHistory = document.getElementById('showCheckoutHistory');
if (checkoutHistory.checked) {
alert("You have elected to show your checkout history.");
} else {
alert("You have elected to turn off checkout history.");
}
Thanks.
source
share