Hello.
Apologies if i have missed this answer elsewhere.
I have a slider, and I want to dynamically update the difference between player 1 and player 2's income as a function of the quantity player 1 gives to player 2 (this quantity is chosen by using the slider).
The below runs fine on a desktop, and works fine in the 'mobile view' when I preview the survey on a desktop. However it does not update when I view the preview on a mobile, nor when I publish and view on a mobile.
Any tips re. getting this to work on a mobile would be much appreciated :)
Qualtrics.SurveyEngine.addOnload(function() {
var give=0;
var give2 = give*2;
var final_difference = 0;
var inc="${e://Field/income_final}";
var partner_inc = "${lm://Field/1}";
this.questionclick = function(event,element){
give = this.getChoiceValue(1);
give2 = give*2;
final_difference = "${e://Field/income_final}" - give - "${lm://Field/1}" - give2 ;
inc = "${e://Field/income_final}" - give;
partner_inc = "${lm://Field/1}" + give2
endupdate();
document.getElementById("final_difference").innerHTML=final_difference;
document.getElementById("give2").innerHTML=give2;
document.getElementById("give").innerHTML=give;
document.getElementById("inc").innerHTML=inc;
document.getElementById("partner_inc").innerHTML=partner_inc;
}
function endupdate() {
give = give;
give2 = give*2;
final_difference = final_difference;
inc = inc;
partner_inc = partner_inc;
}
});
Page 1 / 1
Hi there, ahmedA recommends trying "oninput" in the below thread:
https://community.qualtrics.com/XMcommunity/discussion/19125/check-value-of-dropdown-with-javascript
I've also used "touchstart" with sliders in a different thread with success:
https://community.qualtrics.com/XMcommunity/discussion/19690/change-the-slider-question-clickable-buttons-to-be-a-different-color-for-first-position-only
Hi Tom
Thanks, this is very useful!
For others with similar issues, I ended up using the setInterval function and forcing the values to update every 5ms. Not as nice, but so far no issues with compatibility across devices.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.