Dear Community,
I am looking to auto fill fields in constant sum question to a total of 100.
For example in a two field constant sum question, when one filed is filled as 30 then next one should auto fill as 70 (attaching visual as well).
Could you please help with with this functionality (JS code?)
Many thanks!
Solved
How to setup autofill for constant sum fields or piping for autofill / “must sum to” fields
Best answer by SurajK
Hi Abi ,
Use the below code, assuming you have 2 statements, the below code will work vice a versa i.e. if user change the value in 2nd input then first will get auto fill.
Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery('input[type="text"]').eq(0).change(function(){
var secondinput = jQuery('input[type="text"]').eq(1);
if(jQuery(this).val() > 0)
{
secondinput.val(100-jQuery(this).val())
}
});
jQuery('input[type="text"]').eq(1).change(function(){
var firstinput = jQuery('input[type="text"]').eq(0);
if(jQuery(this).val() > 0)
{
firstinput.val(100-jQuery(this).val())
}
});
});
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

