Hi,
I need to be able to display with live updates an average of 6 inputted numbers.
Basically, I need user to enter their ratings from 1-10 for 6 different questions and then I need the screen to display to them live what their average rating is.
Currently, I am using a "Constant Sum" question. And I can get coding to have the average display in the console log with what I've coded. But I'm having trouble figuring out how to get that to display on the actual screen.
The code I am using is below.
What I want to display (either above or ideally below) the constant sum/input area is:
"Your current average rating is [average]"
I need the [average] to update every time they enter something new (or as per my code on every click)
Qualtrics.SurveyEngine.addOnload(function()
{
var calculateAverage = function() {
currentChoices = document.querySelectorAll("input[name^='QR~QID21']")
numberOfChoices = currentChoices.length
currentSum = 0
for(var i=0; i < numberOfChoices; i++) {
currentSum += parseInt(currentChoices[i].value)
}
currentAverage = currentSum / numberOfChoices
console.log("Current Average: " + currentAverage)
return currentAverage
}
var addBlurHandlers = function() {
currentChoices = document.querySelectorAll("input[name^='QR~QID21']")
for (var i = 0; i < currentChoices.length; i++)
currentChoices[i].onblur = calculateAverage
}
addBlurHandlers()
this.questionclick = function(event,element)
{
calculateAverage();
}
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
console.log("Page loaded...");
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
Need to display a live update of the average of 6 inputted numbers
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.
