I would like to use javascript to select choices in a multi-select MC question based on unselected choices in a previous question.
I’m a little confused by how to do this because most of the related threads I’ve found are asking about selecting choices in conjunction with setting embedded data and/or other functions (and because I’m new to js). I only want to change the answer choice status -- all the other js/piped text/embedded data stuff is happening elsewhere.
(The reason I want to force them to selected state is because I later have to do complex display logic on 200+ answer choices, and the difference between “is displayed” and “is selected” will save me 500-1000 manual menu selections, and it seems like I can get a SelectedChoicesCount to use for embedded data, but not DisplayedChoicesCount.)
Here’s the flow:
Q1: List of tv shows, including distractors; participants select the ones they’ve seen
Q2 (Hidden): List of shows that were unselected in Q1, with distractors removed via advanced randomization
Q3 (Hidden): Long list of video clips, multiple clips per stimulus show that was listed in Q1. Display logic will be used to only display a clip/answer choice if the show was displayed in Q2 and its quota hasn’t been met yet. Then blah blah complicated additional js written by a friend to do other stuff needed for the experiment].
I’d like to add js to Q2 to turn Displayed Choices into Selected Choices. (And then in Q3 I could use display logic to choose selected choices rather than displayed choices, which would save a lot of trackpadding.)
I know that I would use some variation of this:
('inputttype="checkbox"]').x.prop('checked',true);
where x tells it which boxes to check, but I’m not sure what to put in place of x that would mean ‘all displayed choices’.
Later in my survey, I’m doing a 7-item random selection thing from multiple questions and then selecting the answers so they can be used in loop & merge and it (thanks to js friend) looks like:
getRandomSubset( $ANF.find('input:type=checkbox]'), 7 ).prop( 'checked', true );
In a different help thread where the person wanted to check the 1st answer choice, it looks like:
jQuery('input type="checkbox"]').eq(0).prop('checked',true)
...and so on.
Any suggestions on how to make all displayed choices the target for the checked true command?
Thank you!