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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:04:50+00:00 2026-05-24T22:04:50+00:00

so I have spent a day developing and reading (teh other way around) to

  • 0

so I have spent a day developing and reading (teh other way around) to enable my jQuery datepicker to select and highlight mutliple dates.

For this I have managed to write the selected dates to an array which is visualized in a simple textfield.

What I could not manage is to permanently modify the look of the selected date in the datepicker.

I have implemented the “beforeShowDay:” option, which is working properly uppon loading the datepicker, but of course is not called directly on selecting a date.
For this I guessed, I would need to refresh the view “onSelect”, but the refresh is not working properly.
Right now, I have some small methods for handling the datearray.

Uppon adding or removing a date, I am trying to refresh the datepicker.

Uppon selecting a date, I am either adding it to, or remove it from the dates-array.
Also, onSelect, I am matching the selected day and try to addClass().

But once again, I think I missed something all the way round, as it is not shown in my datepicker.

Here’s my code for now:

var dates = new Array();

function addDate(date) {
    if (jQuery.inArray(date, dates) < 0 && date) {
        dates.push(date);
    }
}

function removeDate(index) {
    dates.splice(index, 1);
}

// Adds a date if we don't have it yet, else remove it and update the dates
// textfield
function addOrRemoveDate(date) {
    var index = jQuery.inArray(date, dates);
    if (index >= 0) {
        removeDate(index);
        updateDatesField(dates);
    } else {
        addDate(date);
        updateDatesField(dates);
    }
    jQuery(calContainer).datepicker("refresh");
}


    var calContainer = document.getElementById("calendar-container");

    jQuery(calContainer).datepicker({
        minDate : new Date(),
        dateFormat : "@",
        onSelect : function(dateText, inst) {
            addOrRemoveDate(dateText);

            jQuery(".ui-datepicker-calendar tbody tr td a").each(function() {
                if (jQuery(this).text() == inst.selectedDay) {
                    jQuery(this).addClass("ui-state-highlight");
                    jQuery(this).parent().addClass("selected");
                }
            });
            // addTimeSelectorColumns(dates);
        },
        beforeShowDay : function(_date) {
            var gotDate = -1;
            for ( var index = 0; index < dates.length; index++) {
                if (_date.getTime() == dates[index]) {
                    gotDate = 1;
                } else {
                    gotDate = -1;
                }
            }

            if (gotDate >= 0) {
                return [ true, "ui-datepicker-today", "Event Name" ];
            }
            return [ true, "" ];
        }
    });
function updateDatesField(dates) {

    if (dates.length > 0) {
        var tmpDatesStrArr = new Array();
        var dateString = "";
        var datesField = document.getElementById("dates");

        for ( var index = 0; index < dates.length; index++) {
            var dateNum = dates[index];

            var tmpDate = new Date();
            tmpDate.setTime(dateNum);

            dateString = tmpDate.getDate() + "." + tmpDate.getMonth() + "."
                    + tmpDate.getFullYear();
            tmpDatesStrArr.push(dateString);
        }

        jQuery(datesField).val(tmpDatesStrArr);
    }
}

(I am still a beginner in Javascript/jQuery, so any help or hints towards my coding are welcome, btw…)

  • 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-24T22:04:51+00:00Added an answer on May 24, 2026 at 10:04 pm

    It depends whether you want to stick with jQuery UI or not. If you are open to other library, there is a jQuery Datepicker that supports multiple selection: jquery.datePicker with multiple select enabled. It may save you sometmie fiddling with jQuery UI’s one, as it does not natively support multiple selection.

    EDIT:

    If your main library is not jQuery, I think you should look for a standalone or Prototype-dependent library instead. The JS Calendar looks promising. It natively supports multiple selection by detecting the Ctrl key.

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

Sidebar

Related Questions

I have spent the last day searching and reading various sites and articles to
I have spent the whole day trying to make a script which on submit
I have spent about half a day searching for an answer to this question
I have spent the afternoon trying to wrap my mind around how to translate
I am pretty new to ASP.NET and C# I have spent the day learning
Can two Derby databases run on the same host? I have spent a day
I have spent the last day searching documentation, reviewing forum posts, and googling to
I have spent the whole day trying to make my application use threads but
Ok, I have just spent the whole day playing with DomDocument and creating some
I have spent the day trying to fathom this one out (needless to say

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.