Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8132131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:16:20+00:00 2026-06-06T09:16:20+00:00

I need to show non available dates in different color based on the event

  • 0

I need to show non available dates in different color based on the event type or if it is full booked for that day.

Below example fetches dates from database and i pass them as an array to JavaScript at present i am passing four parameter in an array [2012,7, 15, 'Some events'] such as Year, Month, Day & Years. I want to alter this array to pass Fifth parameter as color [2012,7, 15, 'Some events', 'Red']. so that i can change the color of the cell based on the event type.

I am not sure how i will alter below script to make it work. I have looked for example but could not find a matching one. I would appreciate help in this regard as i am not a Guru of Scripting.

function BindEvents()
{
//Script for Calendar
        var holiDays = [[2012,7, 15, 'Some events'],[2012,7, 4, 'Some Event'],[2012,7, 1, 'Full Booked'],[2012,7, 5, 'Full Booked']];
        $(function () {
            $("#txtBookDate").datepicker({
                dateFormat: "yy-mm-dd",
                minDate: "-0d",
                maxDate: "+90d",
                firstDay: 0,
                beforeShowDay: noWeekendsOrHolidaysOrBlockedDates
            });

            function noWeekendsOrHolidaysOrBlockedDates(date) {
                //var noWeekend = jQuery.datepicker.noWeekends(date);
                return setHoliDays(date);
            }

            // set holidays function which is configured in beforeShowDay
            function setHoliDays(date) {
                var day = date.getDay();
                if (day == 5 || day ==6) return [false, ''];

                for (i = 0; i < holiDays.length; i++) {
                    if (date.getFullYear() == holiDays[i][0]
                        && date.getMonth() == holiDays[i][1] - 1
                        && date.getDate() == holiDays[i][2]) {
                        return [false, 'holiday', holiDays[i][3]];
                    }
                }
                return [true, ''];
            }
        });
}

BindEvents();  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:16:21+00:00Added an answer on June 6, 2026 at 9:16 am

    From the fine manual:

    beforeShowDay

    A function that takes a date as a parameter and must return an array with:

    • [0]: true/false indicating whether or not this date is selectable
    • [1]: a CSS class name to add to the date’s cell or "" for the default presentation
    • [2]: an optional popup tooltip for this date

    The function is called for each day in the datepicker before it is displayed.

    So there’s no room in the return value for a specific color. However, element one of the array can contain multiple class names so you can do it through CSS.

    If you wanted a particular holiday to come out in red text then you could do this in your beforeShowDay:

    return [false, 'holiday red', holiDays[i][3]];
    

    and then add a tiny bit of CSS:

    td.red span.ui-state-default {
        color: #f00;
    }
    

    to make the red class do something.

    Demo: http://jsfiddle.net/ambiguous/pjJGf/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to show different links for US and non-US visitors to my site.
I need to show a div positioned relative to where the link is that
I have a scenario where I need to show a different page to a
I need to plot non-numeric data against dates as a simple line graph. I
I need to make a links section for a django project that show only
I am creating a script that will show your computer information in Non-Geekeese. This
I need to show a report of same set of data with different condition.
I need to create a report using SSRS 2008 that will show the top
Currently I see that a touch event will show me the UIView where the
I have a traditional RDBMS based PHP app that I need to convert over

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.