Checking boxes in Side-by-Side based on embedded data in JS | XM Community
Skip to main content

I have a side-by-side question with (for now) just one column with one column answer.
I would like to check some boxes by default based on embedded data values.
If found some code in from and earlier question here: https://community.qualtrics.com/XMcommunity/discussion/11327/setting-default-choices-using-javascript
if("${e://Field/myvar}" > 0) {
jQuery('#'+this.questionId).find('tbody tr').find('.SBS2').find('input[type="checkbox"]').eq(0).prop('checked',true)
}

However this code does not seem to do anything for me. Could it be that the identifiers (.SBS2 etcetera) have changed?
Kind regards,
Kerwin

Depending upon how many combinations are there, you may be better off using branch logic and setting default choices accordingly.


Hi ahmedA,
Thank you for your response, unfortunately, this is not really an option for our situation as this is part of a broader problem. To elaborate:

  1. We have 2 side-by-side questions with 50 statements each, and multiple colums, on of which is a column with dropdown answers (5 options).

  2. From these 2 side-by-side questions, we want to carry forward the statements in which option 1 OR option 2 from the dropdown answers has been selected. The statements from Q1 will become the rows and the statements from Q2 will become the columns in a Qfinal matrix question.

  3. Since, the carry-forward option does not allow OR operations (i.e. selecting the statements which have received option 1 OR option 2), I need to first create two intermediary side-by-side questions (asdetailed in my original question). These Qinter will be populated with all the statements from Q1 (and Q2 respectively). In JavaScript I will then use piped-text to set embedded variables to True if either option 1 OR option 2 were selected, and this embedded data-field will then be used to check the appriopriate boxes in the Qinter.

  4. Finally, I can carry forward the statements from Qinter for which the boxes were checked, to Qfinal as rows and columns.

I realize this is fairly complex / convoluted, but it's the only option I see to realistically implement a carry-forward with OR conditionals.


You can use OR in display logic for the individual statements. This way you can achieve what you are aiming for without Qinter.
I recommend going with the JS route in situation where its the ONLY available option. Otherwise, even though sometimes more tedious, its better to stick with things that one can customize on their own.


Hi ahmedA,
I see what you mean, but then we have to manually add multiple display logic to over 100 statements, with a lot of room for human error (not to mention if we ever change the statements or order we have to do it all again). If there is a way still to check boxed or default option choices from JS that would be a lifesaver.


Leave a Reply