I would love to get rid of the standard "true" or "false" value of a checkbox when it is checked / unchecked and sent through a form... I wrote this little script but can't make it working, I am obviousliy new to code :)
In short: for a checked checkbox, instead of "true" I would love to have "Réservé" and instead of "false" I would love to have "Non Réservé"... is that possible ?
Have a look at my jsfiddle if you want:
http://jsfiddle.net/anthonysalamin/JySSN/207/
jquery
// wait for DOM to be ready
$(document).ready(function() {
//define the variable for the checkboxes on the page
var allCheckboxes = $("input:checkbox[class=outsider]");
//calls the append function on form submission
$("#form-element").submit(function(event) {
$(allCheckboxes).on('click', function() {
$(this).val(this.checked ? Réservé : Non Réservé);
alert($(this).val());
event.preventDefault();
});
});
});
HTML
<form id="form-element">
<input type="checkbox" class="outsider" />
<input type="submit" value="Send" data-wait="Wait..." />
</form>
Aucun commentaire:
Enregistrer un commentaire