Check if there's at least one answer at each line and the answer in the last column is exclusive (optional).
//surveyscripting.com
//multi3dgridvalidate('Q1', new Array('1', '2'), 5, 'Error message')
function multi3dgridvalidate(qid, answers, scales, qtext)
{
var rez : int = 0;
var gl : int = 0;
for (var z : int = 1; z <= answers; ++z)
{
rez = 0;
for (var k : int = 1; k<=scales; ++k) {
if (f(qid+'_'+k+'x')[z].toBoolean())
{
rez = 1;
}
//uncomment this line if there must be one exclusive answer at the end of the line
if (k != scales) {
if (f(qid+'_'+k+'x')[z].toBoolean() && f(qid+'_'+scales+'x')[z].toBoolean() )
{
rez = 0;
break;
}
}
//
}
if (rez == 0) { gl = 1; }
}
if (gl == 1)
{
RaiseError();
SetQuestionErrorMessage(CurrentLang(), qtext);
}
}