Here is a version of the maxDiff function updated for 2.0x. Changes to behaviour are:
- Random positioning of left/right columns
- Disabling opposite radio in a selected row (instead of pop-up alert)
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
maxDiff({QID});
function maxDiff(qID) {
// Random number between 1 and 2
// Math.floor(Math.random() * (max - min + 1)) + min;
var randomNum = Math.floor(Math.random() * ((2-1)+1) + 1);
// Move the cells around
$('#question'+qID+' table.subquestions-list col:eq('+randomNum+')').prependTo('colgroup.col-responses');
$('#question'+qID+' table.subquestions-list thead tr:eq(0) th:eq('+(randomNum-1)+')').prependTo('#question'+qID+' table.question thead tr:eq(0)');
$('#question'+qID+' table.subquestions-list tbody tr').each(function(i){
$('td.answer-item:eq('+(randomNum-1)+')', this).prependTo(this);
});
// Style stuff
$('#question'+qID+' table.subquestions-list col.odd').css({ 'background-color':'transparent' });
$('#question'+qID+' table.subquestions-list tbody th').css({ 'text-align':'center' });
$('#question'+qID+' table.subquestions-list tbody tr:even td, #question'+qID+' table.question tbody tr:even th').css({ 'background-color':'#F1F1F1' });
$('#question'+qID+' table.subquestions-list tbody tr:odd td, #question'+qID+' table.question tbody tr:odd th').css({ 'background-color':'#FCFCFC' });
// Prevent clicking twice in the same row
$('#question'+qID+' input.radio').on('click', function () {
$('#question'+qID+' input.radio').prop('disabled', false);
$('#question'+qID+' input.radio:checked').each(function(i) {
var thisRow = $(this).closest('tr');
$('input.radio', thisRow).not(this).prop('disabled', true);
});
});
}
});
</script>
Thanks tpartner, I was hoping to randomise the other scale (ie. Product price, colour options, etc, in reference to your example image)
Is that possible?
Thanks for modifying to remove the pop-up
Oh, I see, the question randomization setting affect the answers, not the sub-questions as I thought. I'm traveling today but should have a workaround tomorrow.
Cheers,
Tony Partner Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.