I'm not sure I understand the second requirement but to store a random brand from page 2 and pipe it to page 3, you can do this...
1) Add and manipulate the hidden multi-options question in page 1 as you have already done. Here is updated script that, when inserted into the source of the array,
will automatically detect the question IDs and handle the manipulation.
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify the questions
var q1ID = '{QID}';
var q1 = $('#question'+q1ID+'');
var q2 = $(q1).nextAll('.multiple-opt:eq(0)');
var q2ID = $(q2).attr('id').split('question')[1];
// Hide the hidden question
$('#question'+q2ID+'').hide();
// Assign a class to all "high score" array radio buttons
$('#question'+q1ID+' table.question tbody tr').each(function(i) {
$('input.radio', this).each(function(i) {
if (i > 3) {
$(this).addClass('highScore');
}
});
});
// Interrupt next/submit function
$('form#limesurvey').submit(function(){
// Reset the hidden question
$('#question'+q2ID+' input.checkbox').attr('checked', false);
// Check the appropriate boxes of the hidden question
$('#question'+q1ID+' table.question tbody tr').each(function(i) {
if($('.highScore:checked', this).length > 0) {
$('#question'+q2ID+' li:eq('+i+') input.checkbox').attr('checked', true);
}
});
// Carry on with submit
return true;
});
});
</script>
2) Add a short-text question to page 2 (lets call it randomBrand). Insert this script in the source of the radio on page 2. The script will hide the short-text and then load it with a random visible brand.
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify the questions
var q1ID = '{QID}';
var q1 = $('#question'+q1ID+'');
var q2 = $(q1).nextAll('.text-short:eq(0)');
var q2ID = $(q2).attr('id').split('question')[1];
// Hide the hidden question
$('#question'+q2ID+'').hide();
var brands = new Array();
// Create an array of all visible brands
$('#question'+q1ID+' .answertext:visible').each(function(i) {
brands.push($(this).text());
});
//Load the hidden question with a random brand from the array
var randNum = Math.floor(Math.random()*brands.length);
$('#question'+q2ID+' input.text').val(brands[randNum]);
});
</script>
3) Pipe the short-text value into page 3 with something like:
Here's a copy of the survey back with the scripts in the source of the first questions on page 1 and 2.