I have found great success with this past question but it can't be repeated on the same page. I know there must be a simple way to separate them to their respective questions instead of interacting with each other.
Here is the code:
Qualtrics.SurveyEngine.addOnload(function()
{var $jq= jQuery.noConflict();
$jq('.SumInput:last').attr('readonly',true);$jq('.SumInput').keyup(function(){$jq('.SumInput:last').val(calc());});
function calc(){ var disc = 0; var cp =getVal(parseInt($jq('.SumInput').eq(0).val())); var sp =getVal(parseInt($jq('.SumInput').eq(1).val())); if (cp0)
{ disc = Math.round((cp/sp)*100);
}
return disc; };
function getVal(val){ var fval=0; if (isNaN(parseInt(val)))
{ fval = 0; } else { fval = val; } return fval;
}
});
Thank you!
