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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:28:14+00:00 2026-06-13T04:28:14+00:00

In html page there’s a javascript file whit this content var eventsDates = {

  • 0

In html page there’s a javascript file whit this content

  var eventsDates = {
    "0" :["11-10-2012","21-10-2012","28-10-2012","25-11-2012","15-12-2012"],
    "10":["11-10-2012"],
    "11":["21-10-2012","28-10-2012"],
    "12":["25-11-2012","15-12-2012"]
  }

then through a select I choose the ID to get only a few dates

$('#select_events').bind('change', function(){
    eventsDates = $(eventsDates[$(this).val()]);
});

finally, use this function to build dates and pass them to the datepicker plugin

function available(date) {
    dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
    if ($.inArray(dmy, eventsDates) != -1) {
        return [true, "","Available"];
    } else {
        return [false,"","unAvailable"];
    }
}

to activate datepicker I use this

$('#datepickerEventi').datepicker({
    beforeShowDay:available,
    dateFormat: 'dd/mm/yy'
});

the problem is that the first time it works if I select another value does not work anymore as if the array was empty

Thanks in advance

  • 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-13T04:28:15+00:00Added an answer on June 13, 2026 at 4:28 am

    The array is actually empty because you are overriding the value here:

    $('#select_events').bind('change', function(){
        eventsDates = $(eventsDates[$(this).val()]);
    });
    

    Use another variable name to cache the dates array for the selected event. You could change it to this:

    // default the event dates array to the first option from events dropdown
    var selectedEventDates = eventsDates[$("#select_events option:first").val()];
    
    $('#select_events').bind('change', function(){
        selectedEventDates = eventsDates[$(this).val()];
    });
    

    and update the name here:

    if ($.inArray(dmy, selectedEventDates) != -1) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some html-page. There is a javascript which generates some content. I have
Is there a way to access the page HTML source code using javascript? I
I have a HTML page where there are many <a onclick=javascript> What i need
I have a html page, on this page there are some images, when the
There is a html page customized with css styles(I cannot change this css). One
There is HTML page with contents like this. Documentation at MDN says that childNodes
In this page there's a way to dynamic add html (textbox,input button and radio
There are so many different ways to include JavaScript in a html page. I
Is there any way I can measure out my HTML page and then find
On the page there are links displayed with CSS as buttons: HTML: <a class=button

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.