How can I limit the months shown in this question? | XM Community
Solved

How can I limit the months shown in this question?

  • 22 October 2019
  • 2 replies
  • 3 views

Hello,
I got this question from the Qualtrics library and I am trying to customize it. I have been able to change the years but not been able to limit the months. I only want to show January, September, October, November, and December. Could someone help with customizing the code?

!

Qualtrics.SurveyEngine.addOnload(function()
{

//Set years you would like to have available

var yearFirst = 2019; //Min 2019
var yearLast = 2020; //Max 2020


//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')[0];

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.options[31].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.options[yr.selectedIndex].innerHTML,10)%4!=0)
{
day.options[29].disabled=1;
if(day.selectedIndex==29){day.selectedIndex=28};
}
else
{
day.options[29].disabled=0;
}
}
}

}

yr.onchange=function(){fixer();};
mo.onchange=function(){fixer();};


});
icon

Best answer by KeirJ 23 October 2019, 00:34

View original

2 replies

Userlevel 4
Badge +7
Hi @Grace27!

I think you can simply edit the months by clicking the 'Click here to edit items...' option below the 'Months' column. Then, click on a month to select it and then hit backspace to delete it. Last, click to another question to close the configuration menu.

Give it a shot and let me know if it works for you!

!

!
Yes, it worked! Thank you!!!

Leave a Reply