Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Creating check/error message in checkbox questions

Hi all,

I am trying to implement a check and error message for a set of two free-form check box entry questions that appear on the same page. The basic gist of the questions are the following:

- Q1: asks participants to pick 4 out of 10 products that they like the most (this records in a "checkbox" variable titled something like "Selection_S1").
- Q2: asks participants to choose one of the four selected objects to drop if they had to drop 1 (this records in a "checkbox" variable titled something like "SelectionDrop_S1").

Both Q1 and Q2 show up on the same page, with 10 check boxes in each question so they line up in a table. What I would like the script to do is to check to make sure that the selected "drop" product in Q2 was also initially selected in Q1. If the check fails, meaning a participant chose to drop a product they had not initially selected in Q1, I would like the error message to show and not allow the participant to move forward with the survey until they correct the issue.

Thank you in advance!!
asked Nov 6, 2019 by anonymous

1 Answer

+1 vote
 
Best answer
Does this custom JavaScript verification suit your needs?

for (var i = 1; i <= 10; i++) {
    if (!SSI_GetValue('Selection_S1_' + i) && SSI_GetValue('SelectionDrop_S1_' + i)) {
        strErrorMessage = 'Error message.';
    }
}


The "10" will have to be updated if you change the number of checkboxes each question has.
answered Nov 6, 2019 by Zachary Platinum Sawtooth Software, Inc. (134,400 points)
Yes this worked! Thank you so much!!
...