I have a survey where I have applied randomization in an array question with 5 attributes.
I will need a variable where the randomization is being populated.
I came across a script but it's not working:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
// Identify some stuff
var qHiddenID = {QID}; // The hidden question ID
var qHidden = $('#question'+qHiddenID); // The hidden question
var q1 = $('div.list-radio:eq(0)'); // First radio question on the page
var q1ID = $(q1).attr('id').split('question')[1]; // The first radio question ID
var gID = $('input:text', qHidden).attr('id').split('X')[1]; // The group ID
// Hide this question
$(qHidden).hide();
// Build an array of the Q1 answers
var answersArr = [];
$('input:radio', q1).each(function(i){
var answerID = $(this).attr('id').split('X'+gID+'X'+q1ID)[1];
answersArr.push(answerID);
});
// Load the array into the hidden question
$('input:text', qHidden).val(answersArr);
});
</script>
Well, it's obvious that it doesn't work. I have a survey where I have applied randomization in an array question with 5 attributes.
and var q1 = $('div.list-radio:eq(0)'); // First radio question on the page
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Thank you a lot. I have tested and it's working.
The only problem is that my survey is a question by question survey as requested by the client.
When by group, it is populating the random order variable . But when it is question by question display, the random order variable is blank.
Is there a way to have same thing when display question by question?
Therefore we often recommend to design the survey as
"Each group contains one question" and display "group by group".
This way you have one question per page, but also the freedom to put two or more questions into one group.
This is sometimes desired to show two related questions on one screen, and sometimes necessary to use some workarounds with javascript (e.g. where you merge two questions into one, or like this)
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless