Welcome to the LimeSurvey Community Forum

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

Displaying Multiple text boxes based on numerical Input

  • kateibe
  • kateibe's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 7 months ago #111735 by kateibe
Hello,

I have been trying for the past five hours to figure out how I can have a multiple text box question populate based on the numerical answer from a previous question.

For example I want to ask:

Q1: How many sisters do you have? (numeral input from 1-4 or list radio question from 1-4)
One
Two
Three
Four

Q2: Enter the names of your sisters (multiple text boxes). The text boxes will populate based on the total number of sisters. For example if "3" is input into the numerical input question or if "Three" is selected from the list radio question three text boxes will populate.

I have played around with "array filters", "array exclusions" but have not been able to figure it out. Please help!

Regards,

Kat
The topic has been locked.
More
9 years 7 months ago #111744 by first
Please create a test survey and attached lss export here.

Survey Designer and Programmer
The following user(s) said Thank You: kateibe
The topic has been locked.
  • kateibe
  • kateibe's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 6 months ago #111769 by kateibe
Hello,

Thank you for your prompt response. Please see attached a sample survey.

Thank you!

-Kat
The topic has been locked.
More
8 years 10 months ago #119727 by akanakshaa
Hi,
I am also on the same boat. Would like to know how can I display a certain number of text boxes based on previous numerical input. I want to ask a question as to how many countries are you working and then want to get the names of the countries. If somebody said 7 countries, I need to display 7 text boxes. Is it possible?
Many thanks
The topic has been locked.
More
8 years 10 months ago #119729 by Ben_V
HI,
You can use conditions or (easier) set correctly the "relevance" field for each question...

If your numerical input question code is "Qcountry",

For your text-box #1 the relevance (= condition) is:
((Qcountry.NAOK >= "1"))

For your text-box #2:
((Qcountry.NAOK >= "2"))

For your text-box #2:
((Qcountry.NAOK >= "3"))

etc..


Have a look a the manual too, because relevance use & conditions are really well explained...

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The following user(s) said Thank You: akanakshaa
The topic has been locked.
More
8 years 10 months ago #119733 by akanakshaa
Thank you Ben. I have already tried that. But I would like to use the question type "Multiple short text". Is it possible? Please see the attached images.
The topic has been locked.
More
8 years 10 months ago - 8 years 10 months ago #119763 by Ben_V
Oups sorry, I misunderstood your request...

I suppose you want to display those 2 questions on the same page ? (of course it's easier if on separate pages)
I'm pretty sure that this topic was already answered in this forum, but I'm unable to find this discussion :(
I'll have a look again, if nobody can give you a hand to achieve this...

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Last edit: 8 years 10 months ago by Ben_V.
The following user(s) said Thank You: akanakshaa
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 10 months ago #119776 by tpartner
If you want to use a multiple-short-text in LS 2.05, you will need to use a variation of this workaround - www.limesurvey.org/en/forum/can-i-do-thi...ious-question#119674 . (2.06 will have sub-question relevance)

1) Insert a multiple-choice after the numeric question
2) Filter the multiple-short-text by the hidden question
3) Add the following script to the source of the numeric question.

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function() {
 
    // Identify the questions
    var q1 = $('#question{QID}');
    var qHidden = q1.nextAll('.multiple-opt:eq(0)');
 
    // Hide qHidden
    qHidden.hide();  
 
    // Listeners on the Q1 input
    $('input[type="text"]', q1).on('change keyup', function(e, value) {
 
      var q1Value = $(this).val();
 
      // Reset the hidden question
      $('input.checkbox', qHidden).prop('checked', false);
      $('li.question-item input[type="hidden"]', qHidden).attr('value', '');
 
      // Check the appropriate boxes in qHidden
      $('li.question-item:lt('+q1Value+') input.checkbox', qHidden).prop('checked', true);
      $('li.question-item:lt('+q1Value+') input[type="hidden"]', qHidden).attr('value', 'Y');
 
      // Loop through subquestions in qHidden and fire the Expression Manager checkconditions() function
      $('input.checkbox', qHidden).each(function(i) {
        checkconditions(this.value, this.name, this.type);
      });
    });
  });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...4TP2.lss
File Size:25 KB

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: Ben_V, akanakshaa
The topic has been locked.
More
8 years 10 months ago #119777 by Ben_V

tpartner wrote: ...you will need to use a variation of this workaround...


The quadrature of the circle...!

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 10 months ago #119781 by tpartner
I had to Google "quadrature" :)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
8 years 10 months ago #119782 by Ben_V
better in google.ca if there is some setting options for Quebec...

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 10 months ago #119792 by holch
Hehehe, I think in English it would be "Squaring the circle".

In German it is quite a well used saying "Quadratur des Kreises", which seems to be exactly the same in French. :-)

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.

Lime-years ahead

Online-surveys for every purse and purpose