Is there a method to have by default all sections closed? I have some text populating the statements which is throwing the accordion off. I noticed that if I close the first section then reopen then everything is displayed perfectly.
Its usually only the first statement of a matrix that's expanded. So just add this to your question JS and it should close:
document.getElementById("header~"+this.questionId+"~1").click()
ahmedA , thank you for your reply. This mostly works but still doesn't solve it. The solution closes the first statement, which I thought would be all I needed. It still doesn't look as professional as in the second image in my opening post. This is what it looks like now:
Once I click to open the first statement, then the closed statements pop to looking correctly.
I played around with your solution. If I do this, it works:
document.getElementById("header~"+this.questionId+"~1").click();
document.getElementById("header~"+this.questionId+"~2").click();
document.getElementById("header~"+this.questionId+"~3").click();
document.getElementById("header~"+this.questionId+"~4").click();
document.getElementById("header~"+this.questionId+"~5").click();
document.getElementById("header~"+this.questionId+"~6").click();
document.getElementById("header~"+this.questionId+"~7").click();
document.getElementById("header~"+this.questionId+"~1").click();
okay. Didn't expect that.
In order to avoid repeating the statements. You can use this:
qid = this.questionId;
choices = this.getChoices();
choices.forEach(item => {document.getElementById("header~"+qid+"~"+item).click();});
document.getElementById("header~"+this.questionId+"~1").click();
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.