I have a multiple price list question in Qualtrics. The question type is a matrix table and the matrix type is bipolar. I have a list of choices where the respondents first have to choose between 10 cents or the product, then between 20 cents or the product and so on until 2 euro and the product. This looks like this: "The product" or "€0.10", "The product" or "€0.20", "The product" or "€0.30", ... and so on until "The product" or "€2.00". So 20 rows in total. QID16 is the question ID. I want to edit the JavaScript to make sure only 1 switching point is possible and to make sure that when the respondent chooses for the money, the rest of the following choices will be automatically also for the money. So when the respondent chooses for the product for the first row, nothing happens, but when the respondent chooses for the 1 euro in the 10th row, all subsequent rows will be automatically selected for the money. Also when, for example, the responder is inconsistent and then wants to select 70 cents in the 7th row, automatically the 8th and 9th row will also be selected for the money.
ADMIN NOTE: This post contains AI generated content that may or may not be accurate. For additional questions please contact
Hi
you can try it with this code
Qualtrics.SurveyEngine.addOnload(function() { var qid = 'QID16'; // Replace 'QID16' with your actual question ID
// Function to handle the logic when a choice is selected function handleChoiceSelection(selectedChoice) { var choices = this.questionContainer.select('input'); var choiceIndex = choices.indexOf(selectedChoice); // If a choice for the product is selected, deselect all subsequent choices for money if (selectedChoice.value != 'Product') { for (var i = choiceIndex + 1; i < choices.length; i++) { choicesli].checked = false; } } // If a choice for money is selected, select all subsequent choices for money else { for (var i = choiceIndex - 1; i >= 0; i--) { choicesoi].checked = true; } } }
// Event listener for choice selection this.questionContainer.select('input').invoke('observe', 'click', function(event) { handleChoiceSelection(event.target); });
// Initial setup to ensure only one switching point is possible this.questionContainer.select('input').invoke('observe', 'change', function(event) { var choices = this.questionContainer.select('input'); var selectedChoice = event.target; var selectedValue = selectedChoice.value;
if (selectedValue != 'Product') { var choiceIndex = choices.indexOf(selectedChoice); var previousChoice = choices choiceIndex - 1]; if (previousChoice && previousChoice.value == 'Product') { previousChoice.checked = false; } } }); });
Make sure to replace 'QID16'
with the actual question ID of your multiple price list question in Qualtrics. This script ensures that only one switching point is possible and handles the logic for selecting subsequent choices when a choice for money is selected.
Hi
I´m having the same problem trying to enforce an unique switching point in a MPL question. Has anyone found a solution for this?
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.