Skip to content
Advertisement

Dates select from Mysql to work with bootstrap datepicker

i’m trying to hightlight all dates in datepicker from mysql but is not working, i think the problem is with array or i don;t know, the thing is when i write in user_busy_days variable [‘2019-12-01′,’2019-12-02’]; is working, but with the code below is not working. any help appreciated.

PHP:

JavaScript

Javascript:

JavaScript

Advertisement

Answer

When rendered, this line:

JavaScript

becomes

JavaScript

which is wrapped in a string, so the check $.inArray(calender_date, user_busy_days); is checking against the characters in the string rather than the strings in the array.

Remove the ' so user_busy_days becomes an array:

JavaScript

Extra:

The code (date.getMonth()+1) will also need the 0+slice trick for months 1-9, assuming the php dates output as 2020-01-01 (example only shows 2 digit months)

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement