Hi everyone. Just wanted to share this function that will let you ask array questions one at a time if you have a large list. Can help fight people straight-lining if they don't see a huge table.
Any feedback as to how it can be improved would be much appreciated.
Add this to a js file:
Code:
//Show array rows one at a time
arrayRowShowHide =function(qId){var questionId ='#question'+ qId;var ansArr =[];
$(questionId +' .answers-list').hide();//build array of possbile answers
$(questionId +' .answers-list').each(function(){
ansArr.push([
$(this).children('th').children('input').attr('id'),//sub-q input id
$(this).attr('id')//sub-q tr id]);});var lastAnswer = ansArr.length -1;
$('#'+ ansArr[0][1]).show();
$('.answer-item').click(function(index){//check for and hide questions answered then show first one that's un-answered.
$.each(ansArr,function(index){if(document.getElementById(ansArr[index][0]).value !=""){
$('#'+ ansArr[index][1]).hide();}else{
$('#'+ ansArr[index][1]).show();returnfalse;}});//auto next if last qub-q is answered.if(document.getElementById(ansArr[lastAnswer][0]).value !=""){
$('#movenextbtn').click();}});};