- Posts: 16
- Thank you received: 0
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
- Topic Author
- Offline
- New Member
Less
More
5 years 4 months ago #178047
by lemmon
Dual Scale Array: Set Answer on Second Scale depending on Answer of First was created 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:
Thanks for any assistance
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
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
5 years 4 months ago #178055
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Dual Scale Array: Set Answer on Second Scale depending on Answer of First
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
5 years 4 months ago #178256
by lemmon
Replied by lemmon on topic Dual Scale Array: Set Answer on Second Scale depending on Answer of First
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.
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.
Attachments:
The topic has been locked.