Hi,
is there a way to check in a "constant sum" question, whether the total is "100 or less"?
The "must total" validation only checks whether the total is exactly 100. And I also haven't been able to identify any JS solution.
Thanks!
Manfred
Total of "constant sum" equal or less than 100
Best answer by mvanepps
Hi Manfred,
A colleague had a similar request, so the following JavaScript checked if the total was over 100. The key will be finding the ID of each box in your constant sum question. You can use your debugger to find those (replacing the QR~QID82#1 elements in this example).
The other thing this example is doing is displaying an error message, so after this question, on the same page, I have an empty question that just has this HTML in the question text: . The JavaScript is feeding the message (if needed) into that errorMsg.
Hope this helps!
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
const percentInputs = document.querySelectorAll("input[type=text].InputText");
//Every time someone types in a number add all the boxes together, update the running total, and display error if applicable.
function addItUp(){
if(document.getElementById('QR~QID82#1~1~1~TEXT').value > 100 ||
document.getElementById('QR~QID82#1~2~1~TEXT').value > 100 ||
document.getElementById('QR~QID82#1~3~1~TEXT').value > 100 ||
document.getElementById('QR~QID82#1~4~1~TEXT').value > 100){
document.getElementById("errorMsg").innerHTML = "You've entered a value greater than 100%.";
} else {
document.getElementById("errorMsg").innerHTML = " ";
}
}
//When page loads up we want to listen to all of the text boxes. Add the above function to the boxes.
for (index = 0; index < percentInputs.length; ++index) {
percentInputs[index].addEventListener("keyup", addItUp);
}
});
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
