How to divide an answer and display the result ? | XM Community
Skip to main content

Hi everyone,
I want to ask my respondents their annual salary and display right under their calculated Monthly salary (A mere /12 division). However, they should not be able to modify the Monthly salary.
I am obliged to do so, otherwise 20% of the respondants would enter their Monthly salary instead of the Annual one, and ruin the survey. By displaying their monthly salary they will correct their mistake.
Here an example of what I want to do :
image.pngThank you so much if you know how to help :)

You can use JavaScript like this:
Qualtrics.SurveyEngine.addOnload(function() {
var input =  jQuery("#"+this.questionId+" .InputText")
.after("

Monthly salary:
");
var monthly = jQuery("#"+this.questionId+" .monthly");
input.on("input", function() {
if(isNaN(this.value)) monthly.text("");
else monthly.text((this.value/12).toFixed(0));
});
});


TomG thank you so much !!! It works ! Than you so much you are the best.


Leave a Reply