Regarding Java script | XM Community
Skip to main content
Question

Regarding Java script

  • October 12, 2021
  • 0 replies
  • 18 views

Forum|alt.badge.img+8

I have 50 choices in a matrix question, which I need to show alphabatically and I am using below java script code but its not working. Please help, how can I get is resolved. Its a multiselect matrix question -

Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/

var mylist = jQuery('tbody > tr > th');

var listitems = mylist.children('th').get();

listitems.sort(function(a, b) {

 return jQuery(a).text().toUpperCase().localeCompare(jQuery(b).text().toUpperCase());

});

for (var i=0; i < listitems.length; i++) {

mylist.appendChild(listitems[i]);
}

});