Welcome to the LimeSurvey Community Forum

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

Radio list labels based on previous answers

More
6 years 10 months ago #176371 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
6 years 10 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.
More
6 years 10 months ago #176387 by EdenResident
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
6 years 10 months ago #176391 by jelo
Start reading from here:
www.limesurvey.org/manual/Expression_Man...#Access_to_Variables

Implemented functions in ExpressScript (still called Express_Manager):
www.limesurvey.org/manual/Expression_Man...#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.
More
6 years 10 months ago #176394 by tpartner
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.
More
6 years 10 months ago - 6 years 10 months ago #176395 by tpartner
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:22.73 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 10 months ago by tpartner.
The following user(s) said Thank You: EdenResident
The topic has been locked.
More
6 years 10 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.
More
6 years 10 months ago #176406 by holch
Answer option relevance now!

;-)

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
6 years 10 months ago #176451 by EdenResident
Thanks, tpartner. I was able to do that with nested ifs.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose