I have a current Javascript I use to add additional rows to a matrix table, or rather display hidden rows one at a time as a button is clicked. Can someone please help me modify this to work on a Side by Side question.
Thanks in advance!
Qualtrics.SurveyEngine.addOnload(function()
{
var that=this.questionId;
jQuery("#"+this.questionId+" tr.Choice:not(:lt(3))").hide();
jQuery("").insertAfter("#"+this.questionId+" tr.ChoiceRow:last");
jQuery("#add").on('click',function(){
var c= jQuery("tr.Choice:visible").length;
jQuery("#"+that+" tr.Choice:eq("+c+")").show();
});
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
Need help modifying a Matrix Javascript to work with a Side-by-Side item
Best answer by ahmedA
The following code should work on all types of questions:
Qualtrics.SurveyEngine.addOnReady(function () {
let show_row = 3;
let choice_rows = this.getChoiceContainer().querySelectorAll("[class*='Choice']");
choice_rows[choice_rows.length - 1].insertAdjacentHTML(
"afterend",
""
);
for (i = show_row; i < choice_rows.length; i++) {
choice_rows[i].hide();
}
let add_row = this.getChoiceContainer().querySelector("#row_adder");
add_row.onclick = new_row;
function new_row() {
if (show_row < choice_rows.length) {
choice_rows[show_row].show();
show_row++;
} else {
alert("You've reached the maximum number of permissible rows");
}
}
});
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
