Jquery/Javascript to uncheck all items in a matrix question | XM Community
Skip to main content
Solved

Jquery/Javascript to uncheck all items in a matrix question

  • December 21, 2021
  • 3 replies
  • 135 views

Forum|alt.badge.img

I will say my jQuery/JavaScript is rusty, but the Qualtrics naming and usage has me stumped. I have a two-column matrix question that allows the R to select one or both. I am being asked to create a second question with a check box that (if checked) would uncheck all of the entries in matrix.
Q1 Visited Stayed
Park 1 ___ ___
Park 2 ___ ___
Park 3 ___ ___

Q2
___ I did not visit or stay in any of these parks

Normally, I would put this in the matrix, but the request is to split it out. In the JavaScript for Q2: How do I reference (and set) the boxes accordingly? Is there a best practice for this type of situation? Any sample code would be appreciated.

Best answer by TerryP

I was able to figure it out. It didn't appear that the checkbox below the matrix was able to use the prop. Using .jQuery('QR~QIDn-1').prop('checked', false);  worked.

3 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • December 24, 2021

Yes, we need to add two click events, one for each question's (Matrix and multi select question) checkboxes. Check the demo here.


Forum|alt.badge.img
  • Author
  • January 14, 2022

rondev - Hmm. I was actually looking for code that would do this.


Forum|alt.badge.img
  • Author
  • Answer
  • January 14, 2022

I was able to figure it out. It didn't appear that the checkbox below the matrix was able to use the prop. Using .jQuery('QR~QIDn-1').prop('checked', false);  worked.