Change value of checkbox if checked?

I have a checkbox in a form. The form is submitted via ajax everytime a users makes any chenges to the drop down menu’s in it and returns an updated value. That part is fine.
the part I’m having issues with is the checkbox in the form. Initially it is set to checked. The proble I have is that when the ajax script runs it takes the value from the checkbox regardless of whether it is checked or not!

How can I get around this?
Is there a way to set an initial value and another checked valus on the checkbox?
I’ve had a look and can’t find anyway to do this.

Please help!

I suppose you could modulate the ‘value’ attribute of the checkbox prior to making the AJAX call. The ‘checked’ attribute is separate from that.

Check that the checkbox is checked, before assigning its value.

var form = document.getElementById('myForm');
form.onsubmit = function () {
    var form = this;
    var checkbox = form.elements.myCheckbox;
    checkboxValue = checkbox.checked ? checkbox.value : '';