Hi, on the third option include the below html by going to rich content editor→ Source
<button class="reset">Reset All</button>
<button class="accept">Accept All</button>
Add the below in JavaScript of that question.
Qualtrics.SurveyEngine.addOnload(function() {
var qobj = this;
var q = jQuery("#"+qobj.questionId);
var inputs = q.find(".QuestionBody").find("dtype=radio],otype=checkbox]");
q.find(".accept").click(function() {
inputs.each(function() {
var parts = this.id.split("~");
qobj.setChoiceValue(partsr2], partsr3], true); // Set the value to true to check the option
});
});
q.find(".reset").click(function() {
inputs.filter(":checked").each(function() {
var parts = this.id.split("~");
qobj.setChoiceValue(partsr2], partsr3], false); // Set the value to false to uncheck the option
});
});
});
Hope this helps!
Hi enter the below in html of that option choice, by going in rich content editor → Source.
<button class="reset">Reset All</button>
<button class="accept">Accept All</button>
Add the below in JavaScript of that question
Qualtrics.SurveyEngine.addOnload(function() {
var qobj = this;
var q = jQuery("#"+qobj.questionId);
var inputs = q.find(".QuestionBody").find("dtype=radio],otype=checkbox]");
q.find(".accept").click(function() {
inputs.each(function() {
var parts = this.id.split("~");
qobj.setChoiceValue(partsr2], partsr3], true); // Set the value to true to check the option
});
});
q.find(".reset").click(function() {
inputs.filter(":checked").each(function() {
var parts = this.id.split("~");
qobj.setChoiceValue(partsr2], partsr3], false); // Set the value to false to uncheck the option
});
});
});
Hope this helps!
Hi @spurl
you can use this code:
Qualtrics.SurveyEngine.addOnload(function() {
// Function to handle click event on "Accept All" button
var acceptAllButton = document.getElementById("QR~QID_of_question_3~1");
acceptAllButton.onclick = function() {
// Select "Accept" option for questions 1 and 2
document.getElementById("QR~QID_of_question_1~1").click();
document.getElementById("QR~QID_of_question_2~1").click();
};
// Function to handle click event on "Reject All" button
var rejectAllButton = document.getElementById("QR~QID_of_question_3~2");
rejectAllButton.onclick = function() {
// Select "Reject" option for questions 1 and 2
document.getElementById("QR~QID_of_question_1~2").click();
document.getElementById("QR~QID_of_question_2~2").click();
};
});
Replace "QR~QID_of_question_3~1"
and "QR~QID_of_question_3~2"
with the actual question IDs for the "Accept All" and "Reject All" buttons respectively. Similarly, replace "QR~QID_of_question_1~1"
and "QR~QID_of_question_1~2"
with the actual question IDs for the "Accept" and "Reject" options of question 1, and do the same for question 2.
This code will automatically select the appropriate options for questions 1 and 2 when the "Accept All" or "Reject All" button is clicked, and the changes will be reflected visually in the survey interface.
Thank you, this is super helpful! As an add-on, I'm trying to have any additional clicks on questions 1 and 2 to automatically unclick the accept all and reject all buttons. I already coded the accept all / reject all to be multiple answer with exclusive options (meaning you can deselect an option by clicking). Any suggestions for this?
Hi @spurl
you can use this code:
Qualtrics.SurveyEngine.addOnload(function() { // Function to handle click event on "Accept All" button var acceptAllButton = document.getElementById("QR~QID_of_question_3~1"); acceptAllButton.onclick = function() { // Select "Accept" option for questions 1 and 2 document.getElementById("QR~QID_of_question_1~1").click(); document.getElementById("QR~QID_of_question_2~1").click(); };
// Function to handle click event on "Reject All" button var rejectAllButton = document.getElementById("QR~QID_of_question_3~2"); rejectAllButton.onclick = function() { // Select "Reject" option for questions 1 and 2 document.getElementById("QR~QID_of_question_1~2").click(); document.getElementById("QR~QID_of_question_2~2").click(); }; });
Replace "QR~QID_of_question_3~1"
and "QR~QID_of_question_3~2"
with the actual question IDs for the "Accept All" and "Reject All" buttons respectively. Similarly, replace "QR~QID_of_question_1~1"
and "QR~QID_of_question_1~2"
with the actual question IDs for the "Accept" and "Reject" options of question 1, and do the same for question 2.
This code will automatically select the appropriate options for questions 1 and 2 when the "Accept All" or "Reject All" button is clicked, and the changes will be reflected visually in the survey interface.
Hi @spurl
this i the thing i can think off
Qualtrics.SurveyEngine.addOnload(function() {
// Function to handle click event on "Accept All" button
var acceptAllButton = document.getElementById("QR~QID_of_question_3~1");
acceptAllButton.onclick = function() {
// Select "Accept" option for questions 1 and 2
document.getElementById("QR~QID_of_question_1~1").click();
document.getElementById("QR~QID_of_question_2~1").click();
};
// Function to handle click event on "Reject All" button
var rejectAllButton = document.getElementById("QR~QID_of_question_3~2");
rejectAllButton.onclick = function() {
// Select "Reject" option for questions 1 and 2
document.getElementById("QR~QID_of_question_1~2").click();
document.getElementById("QR~QID_of_question_2~2").click();
};
// Function to handle click events on questions 1 and 2
var question1 = document.getElementById("QR~QID_of_question_1");
var question2 = document.getElementById("QR~QID_of_question_2");
question1.onclick = function() {
// Unclick "Accept All" and "Reject All" buttons
acceptAllButton.checked = false;
rejectAllButton.checked = false;
};
question2.onclick = function() {
// Unclick "Accept All" and "Reject All" buttons
acceptAllButton.checked = false;
rejectAllButton.checked = false;
};
});
i let me know this is what you want and if it works