How to custom code multiple drop down lists with diverse number of choices to hide empty items | XM Community
Solved

How to custom code multiple drop down lists with diverse number of choices to hide empty items

  • 24 September 2018
  • 4 replies
  • 188 views

Hi everyone,
I'm pretty new to Qualtrics and I have some troubles in custom code with Javascript.
In my survey I need to have many drop down lists in the same question; I succeeded in doing this through the Matrix Table, Profile, Drop Down list. The only issue is that the different questions have a different number of possible choices and, editing the scale points, the ones with less choices have a huge number of empty rows. Looking on internet, I found out that I have to use the code " " in order to leave the row empty but I'm not able to hide the row through Javascript. This is the result I have been able to achieve by now:

!

On Qualtrics community (https://stackoverflow.com/questions/48425329/hiding-certain-choices-in-a-qualtrics-matrix), I found out this code as a way to solve my issue (it was actually related to a side by side question but, as I'm still working with a table, I though it could have been a solution):

{
$('QR~QID1~1~2').up('td').childElements().invoke('hide');
});

Actually the code doesn't work and I'm not able to solve this issue. Moreover, I would need to hide all the blank rows of each question without setting the code for each row, is it possible?
Thank you very much in advance for all your answers,

Claudio
icon

Best answer by MohammedAli_Rajapkar 24 September 2018, 11:32

View original

4 replies

Userlevel 7
Badge +20
To avoid javaScript, you can create multiple drop-down question and show it on same page... (you will just have to remove the whitespace between the question)

However, with your approach, you will have to add below code in "OnReady" section of JavaScript:

jQuery("#"+this.questionId+" select option:first-child").text("Select one");

jQuery("#"+ this.questionId + " option").each(function () {
if (jQuery(this).text().length < 2) {
jQuery(this).hide();
}
});

Here is the dummy survey link:
https://qimpl.az1.qualtrics.com/jfe/preview/SV_b17EW36knWzKFMN?Q_SurveyVersionID=current&Q_CHL=preview
Great, it works perfectly. Thank you very much!
Badge +4
Hi Wizard (MR)
I am working on a similar survey with multiple drop-down lists similar to your "dummy survey link" you provided but I cannot duplicate it. Is it possible to provide the qsf file or give more information on how to show on the same page while removing the whitespace between questions...etc?
Thank you in advance

Hi All,
I am working on a similar survey where I have different set of drop down options that are not same in count. I tried to use the above code as suggested, however it does not seem to work. Could anyone please help me with the same?
Thank you in advance.

Leave a Reply