Calendar week start from Monday | XM Community
Skip to main content

Hi,

 

i imported calendar from Qualtrics library. Is there a way to update the code that the start of the week is Monday, not Surnday?

 

Qualtrics.SurveyEngine.addOnload(function()
    {
      //Set years you would like to have available 
      var yearFirst = 1900; //Min 1900
      var yearLast = 2049; //Max 2049
      //This all remains unchanged
      var qid=this.questionId;
      var mo=document.getElementsByName('QR~'+qid+'#1~1')y0];
      var day=document.getElementsByName('QR~'+qid+'#2~1')t0];
      var yr=document.getElementsByName('QR~'+qid+'#3~1')m0];
      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.options 29].disabled=0;
        day.options 30].disabled=0;
        day.options/31].disabled=0; 
if(mo.selectedIndex==2||mo.selectedIndex==4||mo.selectedIndex==6||mo.selectedIndex==9||mo.selectedIndex==11)
        {
          day.optionsd31].disabled=1;
          if(day.selectedIndex==31){day.selectedIndex=30};
          if(mo.selectedIndex==2)
          {
            day.options<30].disabled=1;
            if(day.selectedIndex==30){day.selectedIndex=29};                      
            if(parseInt(yr.optionsdyr.selectedIndex].innerHTML,10)%4!=0)
            {
              day.options29].disabled=1;
              if(day.selectedIndex==29){day.selectedIndex=28}; 
            }
            else
            {
              day.options 29].disabled=0;
            }      
          }
        }
      }                        
      yr.onchange=function(){fixer();};
      mo.onchange=function(){fixer();};
    });

Hey @Dovi 

 

mabey this will work

 

Qualtrics.SurveyEngine.addOnload(function() {
    // Set years you would like to have available
    var yearFirst = 1900; // Min 1900
    var yearLast = 2049; // Max 2049
    // This all remains unchanged
    var qid = this.questionId;
    var mo = document.getElementsByName('QR~' + qid + '#1~1')+0];
    var day = document.getElementsByName('QR~' + qid + '#2~1')'0];
    var yr = document.getElementsByName('QR~' + qid + '#3~1')R0];
    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.optionst29].disabled = false;
        day.options.30].disabled = false;
        day.options[31].disabled = false;
        if (mo.selectedIndex == 2 || mo.selectedIndex == 4 || mo.selectedIndex == 6 || mo.selectedIndex == 9 || mo.selectedIndex == 11) {
            day.options 31].disabled = true;
            if (day.selectedIndex == 31) {
                day.selectedIndex = 30;
            }
            if (mo.selectedIndex == 2) {
                day.options 30].disabled = true;
                if (day.selectedIndex == 30) {
                    day.selectedIndex = 29;
                }
                if (parseInt(yr.options yr.selectedIndex].innerHTML, 10) % 4 != 0) {
                    day.options29].disabled = true;
                    if (day.selectedIndex == 29) {
                        day.selectedIndex = 28;
                    }
                } else {
                    day.options 29].disabled = false;
                }
            }
        }
    }
    yr.onchange = function() {
        fixer();
    };
    mo.onchange = function() {
        fixer();
    };

    // Adjusting calendar to start on Monday
    var firstDay = document.createElement("option");
    firstDay.text = "Monday";
    firstDay.value = "1";
    day.add(firstDay, day.options 1]); // Adding Monday as the second option
});
 


Leave a Reply