There is a webpage which ignores weekends and does not allow the user to select a Saturday or Sunday. I wanted to enable that and while doing internet search I found a piece of code given below that I THINK may be causing this. The issue is I do not know which line to comment or what changes I must do to enable the weekends. Please help
function datepick()
{
var weekend_strtday = <?php echo $this->weekendDatailsArr[0]['weekendstartday']; ?>;
var weekend_endday = <?php echo $this->weekendDatailsArr[0]['weekendday']; ?>;
$('#from_date').datepicker({
beforeShowDay: function(date) {
var day1 = date.getDay();
return [(day1 != weekend_strtday && day1 != weekend_endday)];
},
$('#to_date').datepicker({
beforeShowDay: function(date) {
var day2 = date.getDay();
return [(day2 != weekend_strtday && day2 != weekend_endday)];
},
To use this method you need to add JQuery UI , JQUery and JQUery base theme css.
Here is a modified datepick function that will do that.
Inside
datepick()
these variables stores the weekdays0(sunday) - 6(sataurday)
which cannot be selected by the used.Inside the
beforeShowDay
functionfor more info check here
http://api.jqueryui.com/datepicker/#option-beforeShow
we are checking the current day if it equal to the weekends and returning a array with first index as
true/false
which indicates if that day is selectable or not.UPDATE
To show all the days you just have to remove
beforeShowDay
from the configuration.just select the input
$('#from_date')
and calldatepicker();
method.Check the snippet below,