I\'ve been working on an answer to StackOverflow question Datepicker: Disabling dates in the data. I\'ve successfully developed a small webapp that excludes specific dates from
When getuserdates() in Google Apps Script side returns the value of ["12/13/2019", "12/14/2019", "12/16/2019", "12/17/2019", "12/24/2019"], userdates of var userdates = = getuserdates(); ?> is 12/13/2019,12/14/2019,12/16/2019,12/17/2019,12/24/2019 of the string type. I thought that by this, your script doesn't work.
So, as one of several answers, how about this answer? Please modify JavaScript.html.
In this pattern, the scriptlets are used. I thought that this thread might be useful.
var userdates = ["12/13/2019", "12/14/2019", "12/16/2019", "12/17/2019", "12/24/2019"];
var userdates = [];
var data = getuserdates(); ?>
for (var i = 0; i < data.length; i++) { ?>
userdates.push(= data[i] ?>);
} ?>
userdates is ["12/13/2019", "12/14/2019", "12/16/2019", "12/17/2019", "12/24/2019"].var userdates = = getuserdates(); ?>, you can also modify var userdates = = getuserdates(); ?> to var userdates = = getuserdates() ?>.split(",");.In this pattern, google.script.run is used.
var userdates = ["12/13/2019", "12/14/2019", "12/16/2019", "12/17/2019", "12/24/2019"];
google.script.run.withSuccessHandler(userdates => {
$(function() {
$('#datepicker').datepicker({
minDate: "+3W",
maxDate: "+12W",
beforeShowDay: function (date) {
$thisDate = (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear();
if ($.inArray($thisDate, userdates) == -1) {
return [true, ""];
} else {
return [false, "", "Unavailable"];
}
}
});
});
}).getuserdates();
userdates retrieved from getuserdates() is used as ["12/13/2019", "12/14/2019", "12/16/2019", "12/17/2019", "12/24/2019"].getuserdates() returns ["12/13/2019", "12/14/2019", "12/16/2019", "12/17/2019", "12/24/2019"].If I misunderstood your question and this was not the direction you want, I apologize.
About the reason that the error of Uncaught SyntaxError: Unexpected token '<' occurs, the reason of this issue is != include('JavaScript'); ?>. So please modify as follows.
!= include('JavaScript'); ?>
to JavaScript of != include('JavaScript'); ?>.About the reason that [""12/11/2019"", ""12/15/2019"", ""12/16/2019"", ""12/17/2019"", ""12/24/2019""] is returned from getuserdates(), the reason of this issue is userdates.push('"' + datasheetData[i][5]+ '"');. So please modify as follows.
userdates.push('"' + datasheetData[i][5]+ '"');
userdates.push(datasheetData[i][5]);
When the pattern 1 is used, the script is as follows. About getuserdates() of GAS side, please modify from userdates.push('"' + datasheetData[i][5]+ '"'); to userdates.push(datasheetData[i][5]);. And please modify HTML & Javascript side as follows.
!= include('Stylesheet'); ?>
jQuery datepicker
click here :
!= include('JavaScript'); ?>