admin管理员组

文章数量:1122846

I want to set up a question in qualtrics in which input on one slider changes the value on another slider, but not to a constant sum. In specific, the first slider should take an input (0-1) and the slider below should adjust to 1-(1-input)^2.

Currently, my code looks like this:

Qualtrics.SurveyEngine.addOnload(function() {
    
var currentQuestionInfo = this.getQuestionInfo()
var postTag = currentQuestionInfo.postTag
var currentQuestionID = this.getQuestionInfo().QuestionID;
var Sli1Old = 1;
var Sli2Old = 1;
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 = 1- Math.pow(1 - currentResponse1, 2);
document.getElementById(currentQuestionID +'~2~result').setValue(forceAns2);
document.getElementById(currentQuestionID +'~2~bar').style.width= forceAns2 + "px";
        }
       catch(e) {
        }
    }
    var currentResponse1 = respSli1.value;
    var currentResponse2 = respSli2.value;
    Sli1Old = currentResponse1;
    Sli2Old = currentResponse2;
});
    
    });

I don't know much javascript and am relatively new to qualtrics, so any and all help is appreciated.

本文标签: javascriptDynamically update sliders in QualtricsStack Overflow