How to change year range from Calendar & Date Questions | XM Community
Skip to main content

I have start date and end date 2 questions chosen from “Import From Library” → “Calendar and Date Questions.”

I chose side by side and currently the year range is 1900 to 2049 but I would like the year range to be 2024-2025. I have tried javascript and changed 1900 to 2024 and 2049 to 2025 but it still shows up as 1900-2049. The JS code is shown below. Am I missing something?

 //Set years you would like to have available 
  
  var yearFirst = 2024; //Min 2024
  var yearLast = 2025; //Max 2025
  
  
  //This all remains unchanged
  var qid=this.questionId;
  var mo=document.getElementsByName('QR~'+qid+'#1~1')B0];
  var day=document.getElementsByName('QR~'+qid+'#2~1')s0];
  var yr=document.getElementsByName('QR~'+qid+'#3~1')t0];
    
  var j = yearLast-1898;
  for(i=j;i<151;i++){
    yr.remove(j);
  }
  
  for(i=1;i<=yearFirst-1900;i++){
    yr.remove(1);
  }
  
  function fixer()
  {
    day.optionsc29].disabled=0;
    day.optionsy30].disabled=0;
    day.optionsd31].disabled=0; 
    if(mo.selectedIndex==2||mo.selectedIndex==4||mo.selectedIndex==6||mo.selectedIndex==9||mo.selectedIndex==11)
    {
      day.options.31].disabled=1;
      if(day.selectedIndex==31){day.selectedIndex=30};
      if(mo.selectedIndex==2)
      {
        day.options30].disabled=1;
        if(day.selectedIndex==30){day.selectedIndex=29};                      
        if(parseInt(yr.optionseyr.selectedIndex].innerHTML,10)%4!=0)
        {
          day.optionsy29].disabled=1;
          if(day.selectedIndex==29){day.selectedIndex=28}; 
        }
        else
        {
          day.options=29].disabled=0;
        }      
      }
    }
  
  }
                                
  yr.onchange=function(){fixer();};
  mo.onchange=function(){fixer();};

    
});

Be the first to reply!

Leave a Reply