Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Dual Scale Array: Set Answer on Second Scale depending on Answer of First

  • lemmon
  • lemmon's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 10 months ago #178047 by lemmon
I have some code that will set the answer of the second scale for a hard coded subquestion, but how would I expand this to automatically set this answer depending on which subquestion is clicked? The second scale automatic answer ("None") should only be applied if the first answer is clicked in the first scale ("Never"). The following screenshot illustrates this better than I can describe in words:



I am using LS 3.14

My code:
Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
    // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Loop through first-row answers
    $('tr.answers-list:eq(0) input[type="radio"]', thisQuestion).each(function(i) {
 
      // Click the fourth column
      if(i == 4) {
        var thisName = $(this).attr('name');
        if($('input[type="radio"][name="'+thisName+'"]:checked', thisQuestion).length == 0) {
          $(this).trigger('click');
        }
      }
    });
  });
</script>
 

Thanks for any assistance
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago #178055 by tpartner
Can you attach a small sample survey (.lss file) containing only the relevant question?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • lemmon
  • lemmon's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 10 months ago #178256 by lemmon
I have attached a survey with a sample question. You can see that the question has two scales: one for frequency and one for intensity:
It is clear that if the user selects "never" for Frequency, the answers "a little", "a lot", "extreme" for Intensity make no sense. That is why I would like to automatically select "none" for Intensity if the user selects "never" on the Frequency scale.

I have some code in there, but it is not dynamically selecting "never" if the user selects "none" for a subquestion.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose