i have a form to update personnal data with multiple checkboxes who can be initially checked or not.
<form method="post" id="up_mission">
<input checked type="checkbox" id="first">
<input type="checkbox" id="second">
<button class="btn btn-default" type="submit" id="update_mission<?php echo $id_mission ?>"</button>
</form>
and the JS:
$(function() {
$("form[id^='up_mission']").submit(function() {
var value1 = document.getElementById("first").checked;
var value2 = document.getElementById("second").checked;
$.post("update_mission.php", {value1: value1, value2:value2}, functon(data) { console.log(data) });
});
});
in update_mission.php there is a simple sql querry to update with news values and i also do var_dump($_POST); and the values printed for first and second are always the ones that i initially put in the it doesn't matters if i uncheck or check the checkbox.
How can i fix it please?
Aucun commentaire:
Enregistrer un commentaire