Hello,
I am trying to have two sliders in a question which automatically update one another. If I change the value of the first slider to x, the second slider should update to 500-x. My current code is:
var currentQuestionInfo = this.getQuestionInfo()
var postTag = currentQuestionInfo.postTag
var currentQuestionID = this.getQuestionInfo().QuestionID;
var Sli1Old = 250;
var Sli2Old = 250;
var DomSli = 0;
var respSli1 = document.getElementById(currentQuestionID + '~1~result');
var respSli2 = document.getElementById(currentQuestionID + '~2~result');
Event.observe(document, 'mouseup',function(e){
var currentResponse1 = respSli1.value;
var currentResponse2 = respSli2.value;
if( currentResponse1 != Sli1Old ) {
DomSli = 1;
} else {
DomSli = 2;
}
if( DomSli == 1) {
try {
var forceAns2 = 500 - currentResponse1;
this.setChoiceValue(2, forceAns2);
}
catch(e) {
}
}
var currentResponse1 = respSli1.value;
var currentResponse2 = respSli2.value;
Sli1Old = currentResponse1;
Sli2Old = currentResponse2;
});
All the variables work and the current responses are read out correctly. However, the setChoiceValue function does not work. Any idea on how to fix this?
Thanks in advance!
How to set the value on a slider through Javascript
Best answer by exp_economist
Figured this out by myself, in case anyone cares. It is:
var forceAns2 = 500 - currentResponse1;
document.getElementById("QID9~2~result").setValue(forceAns2);
document.getElementById("QID9~2~bar").style.width= forceAns2 + "px";
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.
