Welcome to the LimeSurvey Community Forum

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

Radio list labels based on previous answers

  • EdenResident
  • EdenResident's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 4 months ago #176371 by EdenResident
Radio list labels based on previous answers was created by EdenResident
Hello, I'd like to create a survey that works like this.

A1. Please enter the names of the household members (multiple text input)
Person 1: [Textbox]
Person 2: [Textbox]
Person 3: [Textbox]
...

Person 10: [Textbox]


B1. Please select which HH member you would like to interview (Radio list)
  • Name of person 1 entered from A1
  • Name of person 2 entered from A1
  • ...
  • Name of person 10 entered from A1

Please let me know if this is possible. Thanks.
The topic has been locked.
More
5 years 4 months ago #176382 by jelo
LimeSurvey is currently lacking answer relevance (multichoice answers are subquestions, which already have sub-question-relevance). You could use a multi-choice question with a answer limit of 1 (which would be the same as a radio button question) instead.

Displaying the entered text in a different question is not the problem.

There might be other workarounds, but the answer-relevance is overdue.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: EdenResident
The topic has been locked.
  • EdenResident
  • EdenResident's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 4 months ago #176387 by EdenResident
Replied by EdenResident on topic Radio list labels based on previous answers
Hi jelo, thanks for the workaround. That works great for me. I have another question if you don't mind.

So after the user selects the member he wants to interview (from the multiple choice), I want to get and store that name. Provided that my variables are coded like this

A1:
PERSON
01 (subquestion)
02
...

B1:
SELECTEDPERSON
01 (subquestion - multiple choice)
02 (subquestion - multiple choice)
..

Then, to get the name of the selected person, I'd assume that the syntax would be like this {PERSON_{SELECTEDPERSON}}

However, the nesting of variables obviously didn't work for me. So, is there like an eval function in Limesurvey?
The topic has been locked.
More
5 years 4 months ago #176391 by jelo
Start reading from here:
manual.limesurvey.org/Expression_Manager#Access_to_Variables

Implemented functions in ExpressScript (still called Express_Manager):
manual.limesurvey.org/Expression_Manager#Access_to_Functions

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #176394 by tpartner
Replied by tpartner on topic Radio list labels based on previous answers
You can use nested IF statements to display the value from the first question. So, given the question and sub-question codes indicated above, something like this (line-breaks inserted for clarity):

Code:
{if(!is_empty(SELECTEDPERSON_01), PERSON_01, 
  if(!is_empty(SELECTEDPERSON_02), PERSON_02, 
    if(!is_empty(SELECTEDPERSON_03), PERSON_03, 
      if(!is_empty(SELECTEDPERSON_04), PERSON_04, 
        if(!is_empty(SELECTEDPERSON_05), PERSON_05, '')))))}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: EdenResident
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago - 5 years 4 months ago #176395 by tpartner
Replied by tpartner on topic Radio list labels based on previous answers
Regarding using a multiple-choice question with maximum answers of 1 to replicate a radio question, you can insert this script in the question source to automatically uncheck other options as options are checked.

Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Listener on the checkboxes
    $('input:checkbox', thisQuestion).on('change', function(e) {
      if($(this).is(':checked')) {
        $('input:checkbox', thisQuestion).not(this).prop('checked', false).trigger('change');
      }
    });
  });
</script>

Here is a small sample survey incorporating both of these concepts:

File Attachment:

File Name: limesurvey...4872.lss
File Size:23 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 4 months ago by tpartner.
The following user(s) said Thank You: EdenResident
The topic has been locked.
More
5 years 4 months ago #176402 by jelo
Tony, since I forgot to ask the thread-starter what LS version is in use, we should add that your nice workaround is for LS 3.X.

That answer-relevance is not available in LS3 and LS4 as well, is a pity (or more).

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: tpartner
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #176406 by holch
Answer option relevance now!

;-)

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • EdenResident
  • EdenResident's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 4 months ago #176451 by EdenResident
Replied by EdenResident on topic Radio list labels based on previous answers
Thanks, tpartner. I was able to do that with nested ifs.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose