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 7542185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:05:57+00:00 2026-05-30T08:05:57+00:00

I am trying to make a jquery datepicker calendar that would highlight holidays and

  • 0

I am trying to make a jquery datepicker calendar that would highlight holidays and make the holiday name as a tooltip when the day on the datepicker is hovered. The holiday dates came from a php file ( holidays.php ). My problem is..I can’t seem to highlight ALL the holidays instead, it highlights just one date. More specifically, just the first returned date.

$(document).ready(function (){
  var holiDays = (function () {
    var val = null;
    $.ajax({
        'async': false,
        'global': false,
        'url': 'holidays.php',
        'success': function (data) {
        val = data;
        }
    });
    return val;
    })();

  var result = [];
  var holiDays = holiDays.split(',');

 var s, k;

    for (s = 0, k = -1; s < holiDays.length; s++) {
        if (s % 4 === 0) {
            k++;
            result[k] = [];
        }

        result[k].push(holiDays[s]);
    }

  // This for loop is to check whether the values stored in result[] are correct

  for (i = 0; i < result.length; i++) {
  var f=result[i][0]+"-"+result[i][1]+"-"+result[i][2];
  alert(f); 
  }


  function nationalDays(date) {
    var m = date.getMonth();
    var d = date.getDate();
    var y = date.getFullYear();

  for (i = 0; i < result.length; i++) {
  var f=result[i][0]+"-"+result[i][1]+"-"+result[i][2];
 // WHEN I ALERT THE VALUE OF f HERE, 
 // IT ALWAYS DISPLAY THE FIRST VALUE IN THE RESULT ARRAY. WHY?
 alert(f);

  var d = new Date(f);

                 if (date.getFullYear() == d.getFullYear()
                      && date.getMonth() == d.getMonth()
                      && date.getDate() == d.getDate()) {
                    return [true, 'holiday', result[i][3]];
                 } else {
                  return [true];
                 }
               } 

  }


  $(function() { 
        $('input.pickerClass').live('click', function() {
            $(this).datepicker({dateFormat: 'yy-mm-dd', beforeShowDay: nationalDays  }).focus();
        });

  });



});

when I alert the values inside the array result[] outside of the nationalDays function, the values stored seemed to be correct.

  for (i = 0; i < result.length; i++) {
  var f=result[i][0]+"-"+result[i][1]+"-"+result[i][2];
  alert(f); 
  }

but for some reason, when I alert the values of the result[] INSIDE the for loop under the nationalDays function, it only returns the first date stored in the array result[]. But why?

Anyone has ideas?.. I would appreciate it so much. 🙂

  • 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-05-30T08:05:58+00:00Added an answer on May 30, 2026 at 8:05 am

    I already know where I’ve gone wrong.

    if (date.getFullYear() == d.getFullYear()
                          && date.getMonth() == d.getMonth()
                          && date.getDate() == d.getDate()) {
                        return [true, 'holiday', result[i][3]];
                     } else {
                      return [true];
                     }
    

    Should have been

    if (date.getFullYear() == d.getFullYear()
                          && date.getMonth() == d.getMonth()
                          && date.getDate() == d.getDate()) {
                        return [true, 'holiday', result[i][3]];
                     } 
                      return [true];
    

    I just removed the else statement and it worked!

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

Sidebar

Related Questions

I'm trying to make a jquery tooltip that appears when a user mouses over
I am trying to make a jquery menu that when I click on one
I'm trying to make a jQuery plugin that executes a method on a timer.
Trying to make simple jQuery function to create a scrollToTop button that fades in
I have been trying to make jquery datepicker plugin work on a content page
im trying to make jquery box drag, but the problem is that when i
I'm trying to make Jquery delete function, here is the code, that I wrote
I'm trying to make a function that uses jquery's ajaxfunction to get some info
I'm trying to make sure that my JQuery ready function is working. In the
I'm trying to make a Jquery plugin ( findFirst() ) to find the first

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.