The code we're using is below - it also includes functions to replace zeros with blank space and widens the input boxes:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
var a = 0;
var b = 0;
while (a<6){
while (b<9){
if(this.getChoiceValue(a,b) == 0) {
this.setChoiceValue(a,b,"");
}
b++;
}
b = 0;
a++;
}
{
var inputWidth = "75px";
var q = jQuery("#"+this.questionId);
q.find('Input').css("width", inputWidth);
q.find('.SumInput').css("width", inputWidth);
q.find('.SumTotal').css("width", inputWidth);
q.find('.InputText').css("width", inputWidth);
};
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
this.questionclick = function(event,element){
var i =0; /*Setting column number for loopage*/
while (i<9){
var a = parseInt(this.getChoiceValue(1,i),10);
var b = parseInt(this.getChoiceValue(2,i),10);
var c = parseInt(this.getChoiceValue(3,i),10);
var d = parseInt(this.getChoiceValue(4,i),10);
var e = parseInt(this.getChoiceValue(5,i),10);
if(isNaN(a)){ /*check if div by 0*/
a= 0;
}
if(isNaN(b)){ /*check if div by 0*/
b= 0;
}
if(isNaN(c)){ /*check if div by 0*/
c= 0;
}
if(isNaN(d)){ /*check if div by 0*/
d= 0;
}
if(isNaN(e)){ /*check if div by 0*/
e= 0;
}
var x = a+b+c+d+e ;
this.setChoiceValue (6,i,x);
/*Increase column number*/
i++;
}}
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
Any ideas on the error??
Thanks,
RoseSolved
Anyone know what this error message means?
Hi everyone,
My team has put together some JS to create an additional constant sum total on a matrix table. It works perfectly, but when we go to submit the data on the preview it comes up with the below error:
!
The code we're using is below - it also includes functions to replace zeros with blank space and widens the input boxes:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
var a = 0;
var b = 0;
while (a<6){
while (b<9){
if(this.getChoiceValue(a,b) == 0) {
this.setChoiceValue(a,b,"");
}
b++;
}
b = 0;
a++;
}
{
var inputWidth = "75px";
var q = jQuery("#"+this.questionId);
q.find('Input').css("width", inputWidth);
q.find('.SumInput').css("width", inputWidth);
q.find('.SumTotal').css("width", inputWidth);
q.find('.InputText').css("width", inputWidth);
};
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
this.questionclick = function(event,element){
var i =0; /*Setting column number for loopage*/
while (i<9){
var a = parseInt(this.getChoiceValue(1,i),10);
var b = parseInt(this.getChoiceValue(2,i),10);
var c = parseInt(this.getChoiceValue(3,i),10);
var d = parseInt(this.getChoiceValue(4,i),10);
var e = parseInt(this.getChoiceValue(5,i),10);
if(isNaN(a)){ /*check if div by 0*/
a= 0;
}
if(isNaN(b)){ /*check if div by 0*/
b= 0;
}
if(isNaN(c)){ /*check if div by 0*/
c= 0;
}
if(isNaN(d)){ /*check if div by 0*/
d= 0;
}
if(isNaN(e)){ /*check if div by 0*/
e= 0;
}
var x = a+b+c+d+e ;
this.setChoiceValue (6,i,x);
/*Increase column number*/
i++;
}}
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
Any ideas on the error??
Thanks,
Rose
The code we're using is below - it also includes functions to replace zeros with blank space and widens the input boxes:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
var a = 0;
var b = 0;
while (a<6){
while (b<9){
if(this.getChoiceValue(a,b) == 0) {
this.setChoiceValue(a,b,"");
}
b++;
}
b = 0;
a++;
}
{
var inputWidth = "75px";
var q = jQuery("#"+this.questionId);
q.find('Input').css("width", inputWidth);
q.find('.SumInput').css("width", inputWidth);
q.find('.SumTotal').css("width", inputWidth);
q.find('.InputText').css("width", inputWidth);
};
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
this.questionclick = function(event,element){
var i =0; /*Setting column number for loopage*/
while (i<9){
var a = parseInt(this.getChoiceValue(1,i),10);
var b = parseInt(this.getChoiceValue(2,i),10);
var c = parseInt(this.getChoiceValue(3,i),10);
var d = parseInt(this.getChoiceValue(4,i),10);
var e = parseInt(this.getChoiceValue(5,i),10);
if(isNaN(a)){ /*check if div by 0*/
a= 0;
}
if(isNaN(b)){ /*check if div by 0*/
b= 0;
}
if(isNaN(c)){ /*check if div by 0*/
c= 0;
}
if(isNaN(d)){ /*check if div by 0*/
d= 0;
}
if(isNaN(e)){ /*check if div by 0*/
e= 0;
}
var x = a+b+c+d+e ;
this.setChoiceValue (6,i,x);
/*Increase column number*/
i++;
}}
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
Any ideas on the error??
Thanks,
RoseBest answer by LaurenK
Hey @rose_b! If you have not yet already, I would recommend reaching out to our Support Team so they can further troubleshoot this with you!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
