Hello, I want to insert text labels like 'Yes' and 'No' into rows of an array. Those labels depend on another random variable that is created in the survey called "RANDOM".
The result should look like this attached image:
I have tried to find a solution from this thread:
www.limesurvey.org/forum/design-issues/1...ubheaders-and-labels
Unfortunately, I have almost no experience using JavaScript.
My main problem is to implement a placeholder into JavaScript that refers to my RANDOM variable.
The code that I tried -- that
does NOT work -- looks like this:
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
// Identify this question
var thisQuestion = $('#question{QID}');
var placeHoldOne = $('#question{if(RANDOM == 1 or RANDOM == 2, "Yes", "No")}');
var placeHoldTwo = $('#question{if(RANDOM == 1 or RANDOM == 2, "Yes", "No")}');
var placeHoldThr = $('#question{if(RANDOM == 1 or RANDOM == 3, "Yes", "No")}');
var placeHoldFou = $('#question{if(RANDOM == 1 or RANDOM == 4, "Yes", "No")}');
// Insert the new header row
$('tr.answers-list:eq(0)', thisQuestion).before('<tr class="ls-heading"><td class="" style="text-align: left;">Option 1</td>'+'<th class="answer-text">'+placeHoldOne+'</th>'+'<th class="answer-text">'+placeHoldTwo+'</th></tr>');
$('tr.answers-list:eq(0)', thisQuestion).before('<tr class="ls-heading"><td class="" style="text-align: left;">Option 2</td>'+'<th class="answer-text">'+placeHoldThr+'</th>'+'<th class="answer-text">'+placeHoldFou+'</th></tr>');
});
</script>
Attached is the whole conjoint survey with the random variable.
Thank you very much for your attention!