first of all sorry for my english
I would like to change available days of a datepicker based on a checkbox value. I'm using Contact form 7 and jQuery.ui, the text field initialize the datepicker correctly, but i can't make it change based on the value of a checkbox. I have 5 checkboxes on a form, wich are Physicals Place where the client is working, you can order stuff and pickup directly from his location (Food truck just to be clear) and then pick a date. What i want to achive is hide days of the week based on the checkboxes, as an example:
-
Checkbox = Place A (Only Mondays)
-
Checkbox = Place B (Only Fridays)
And so on.
What i have so far:
//I will be more specific with the selector as soon as i get it to work
jQuery("input[type=checkbox]").on('click', function () {
cVal = jQuery(this).val();
});
jQuery(function(){
jQuery(".cf7date").datepicker({
beforeShowDay: function(date) {
var day = date.getDay();
return [(day != 0 && day != 6), ''];
}
});
});
This is removing saturday and sunday and is working fine I can get the value of the clicked checkbox, but no matter what i try, the datepicker will stop work if wrapped inside an if/switch to check the checkbox value and output different days.
And i'm kinda confused on how to pass the "cVal" variable outside the click function
Any help would be appreciated, thank you very much
Aucun commentaire:
Enregistrer un commentaire