Hello!!!
I have examined event listeners for the Constant Sum question rows in my Google Chrome Developer Tools. I am setting the value of one row on page load (the total sum of a previous Constant Sum question in the same survey, and the value needs to be overwritten whether the response is new or edited). Of course, because the value is set on page load, I will need to manually trigger the event to which the update of the Total field is attached.
The problem? Both the change and input events have parameterless functions attached to them, and in my limited knowledge of Javascript, neither function translates as anything I would recognize as updating the sum. The first screenshot is of the row I am trying to update, and the second is of my code with the conundrum.
Thank you!!!
Stuart
Your assumption about input ids is wrong so you are never getting to the event handlers. It is generally best to avoid hard coding ids.
Anyway, here is a simplified way to do it:
Qualtrics.SurveyEngine.addOnload(function() {
var traineesSum = parseInt("${e://Field/traineesSum}");
if(!isNaN(traineesSum)) {
jQuery("#"+this.questionId+" .InputText:first").val(traineesSum).blur().prop("readonly",true);
}
});
I forgot to mention that when I looked in Chrome Developer Tools, I could see which events had elements with listeners attached to them. The input elements have no listener attached to the blur event. For that reason, blur() will not work. By contrast, the input elements DO have listeners for the change event, and as I mentioned before, the listeners also exist on the input event. For that reason, I believe, the correct method is either change() or input(), not blur(). I will let you know of my results.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.