Welcome to the LimeSurvey Community Forum

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

Array(Texts) with dropdown conditions

  • GiuliaDonati
  • GiuliaDonati's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 7 months ago #225498 by GiuliaDonati
Array(Texts) with dropdown conditions was created by GiuliaDonati
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
Hello, I am new to lime survey...and struggling with array type questions, dropdown and exclusive conditions.

I have an array(text) type of question. It has three columns (Amt1,Amt2,Amt3) that each have a dropdown list (selection of names). I would like to set an exclusive condition for columns 2 and 3 (i.e. Amt1, Amt2) for each row of my array, if people select one of the elements in the 1st column for example. This to avoid that they select multiple times the same element (i.e. name) per row.

I am attaching the question. I would be very grateful for any help/input provided.

Best wishes

Giulia

 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 7 months ago #225500 by Joffm
Replied by Joffm on topic Array(Texts) with dropdown conditions
Hi,
1. Why didn't you answer the initial questions?
2. Please, always attach a lss export, neither lsq nor lsg.
Reason: 
lsq and lsg exports are language sensitive. You can't import these exports into a survey with a different base language.
So, to import such an export we volunteers have to guess the base language, create a new survey, create a group and then we may import the lsq export.
Please, ease our life.
And we always ask for the relevant questions, not the whole survey.
To do this, copy the survey, remove everything not related to your question and send this as lss export.

3. To answer your question.
The best and easiest is to validate the question, like
unique(Q1_Y001_X001,Q1_Y001_X002,Q1_Y001_X003) and
unique(Q1_Y002_X001,Q1_Y002_X002,Q1_Y002_X003) and
unique(Q1_Y003_X001,Q1_Y003_X002,Q1_Y003_X003) and 
...

Some further remarks if you ask this in the German part.

​​​​​​​Joffm
​​​​​​​

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: LISHANGQI

Please Log in to join the conversation.

  • GiuliaDonati
  • GiuliaDonati's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 7 months ago #225502 by GiuliaDonati
Replied by GiuliaDonati on topic Array(Texts) with dropdown conditions
Dear Joffm,

Thank you for your quick reply,  much appreciated.

I am attaching the lss export, sorry I did not know, well noted for a next time. I actually have 2 issues.

[Q1] which is the one you replied to:

1. I don't understand what you mean by "why didn't you answer the initial questions?". I would like to leave the option [...] standing for "no collaboration".

To give some context. Participants should select at least one row (in this case municipality names, e.g. Baden). Then they have to specify the section of the municipality they work with (see dropdown menu e.g. Raumentwicklung). I would like to avoid that if participants select one element of the dropdown menu in the first column e.g. Amt1, that they also repeat it in columns 2 and 3. I understand you point with "unique(Q1_Y001_X001,Q1_Y001_X002,Q1_Y001_X003)". However I am not sure where and how I should put this in the question.

For [Q2]

It's similar, but here I would like to insert dropdown menus in this dynamic array(text). Here the columns Amt1,Amt2,Amt3 would need to have the same "unique" conditions per unique Gemeinde. Here the list of Gemeinde is not predefined, but I would like them to chose from a selection of 200 Gem1,Gem2,...that I will offer alphabetically ordered.


I hope I was more or less clear...

Thank you very much for your time and any help provided,

Regards

Giulia 

NB (I am not a German speaker, although the survey will have to be in German...)

 

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 7 months ago #225507 by holch
Replied by holch on topic Array(Texts) with dropdown conditions

1. I don't understand what you mean by "why didn't you answer the initial questions?"


When you start a new topic, there are a couple questions that you are supposed to answer, to help the helpers in the forum. If you don't do it, we most probably will ask them right away. Why not help us helping you by answering these questions from the start (which version of LS you run on, which survey theme you use, if it is selfhosted or hosted by the Limesurvey GmbH).

Instead of actively deleting those questions it would be a good idea to respnd them:
 


 

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

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 7 months ago - 2 years 7 months ago #225508 by Joffm
Replied by Joffm on topic Array(Texts) with dropdown conditions
Hi,
1. There is something obsolete in the script.
This script sets the third column to "readonly", if there is a certain condition in the second column.
This has to be removed.
And this line of code
$('select[name="select1"] option[value="2"]').attr('selected','selected');

You enter the validation equation in "question validation equation" in "Logic"
 
To understand the "self" variable, please read here
[url] manual.limesurvey.org/ExpressionScript_-....22that.22_variables [/url]
In short: "self" is replaced by the actual question code; so you have not to care about.
Therefore, enter this
unique(self.sq_SQ001_X001,self.sq_SQ001_X002,self.sq_SQ001_X003) and
unique(self.sq_SQ002_X001,self.sq_SQ002_X002,self.sq_SQ002_X003) and
...
for all subquestions.

And a "question validation tip" to explain
 




2. Here you do exactly the same.
But how do you want the participants to select the "Gemeinde"?
Also a drop-down?
Or an "autocomplete"-solution?
Both is possible.

Later I will send an example.

Joffm

And regarding the initial questions.

Weren't they displayed when you created this topic?



 
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 7 months ago by Joffm.

Please Log in to join the conversation.

  • GiuliaDonati
  • GiuliaDonati's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 7 months ago #225513 by GiuliaDonati
Replied by GiuliaDonati on topic Array(Texts) with dropdown conditions
To Holch and Joffm,

Sorry again, it's my very first time engaging on such a Forum (and LimeSurvey). Here below you will find the responses to the initial questions.

Please help us help you and fill where relevant:
Your LimeSurvey version: version 3.15.9+190214
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template: template: eawagls3
==================
(Write here your question/remark)

1.) Correct a part was obsolete... I used the script from another question, where there was a condition for the 3 column according to values of the second column...the overall structure of the question seemed to have an appropriate structure...but I missed to remove the unnecessary parts..

Now, I did remove the following part:// 3rd column conditional on 2nd column
      if($(this).closest('.answer-item').hasClass('answer_cell_X002')) {
         handleColumnX003($(this));
      }
    });

    function handleColumnX003(thisSelect) {
      var thisRow = $(thisSelect).closest('tr.subquestion-list');
      var item3 = $('.answer_cell_X003', thisRow);
      if($(thisSelect).val() < '3') {
        $('.inserted-select', item3).prop('disabled', false);
        $('input:text', item3).val('4').trigger('change');      }
      else {
        $('.inserted-select', item3).val('').prop('disabled', true);
        $('input:text', item3).val('').trigger('change');
      }
    }


I also removed the 

$('select[name="select1"] option[value="2"]').attr('selected','selected');

----

Thank you very much for the "question validation equation" in "Logic" indications, I did apply them. However, I do not yet get your outputs...

I am attaching again a new version of the survey I have.

----

For question [Q2]

Having an autocomplete"-solution I think would be very useful indeed !!

I would still be very much interested in both options. But whatever takes less time for you will do, I already appreciate very much the help provided so far.

Best wishes

Giulia

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 7 months ago #225516 by Joffm
Replied by Joffm on topic Array(Texts) with dropdown conditions
Quick answer to the validation issue.
You copied it (from the forum post?)

There are linefeeds included.
 

Remove them.

If an equation isn't displayed in the "logic" syntax, it is always a good idea to put it into the question text (with curly brackets). You will see.
Here you see some examples
[url] manual.limesurvey.org/ExpressionScript_How-tos/en [/url]

And: Is it really hosted at LimeSurvey GmbH?
I am surprised that it is such an old release (more than 3 years old)

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • GiuliaDonati
  • GiuliaDonati's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 7 months ago #225518 by GiuliaDonati
Replied by GiuliaDonati on topic Array(Texts) with dropdown conditions
Thank you very much for the syntax link and the tip, indeed I had spaces.. ! this worked :)

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 7 months ago - 2 years 7 months ago #225527 by Joffm
Replied by Joffm on topic Array(Texts) with dropdown conditions
Hi,
here an example 
1. The "old" solution.
2. The second question with a "autocomplete" in the first column.
At the moment you will find the countries of the world.
 

File Attachment:

File Name: limesurvey...5286.lss
File Size:52 KB

 




Be aware, that this solution is hard to analize. You will get the name of the town. 
And these names can be spreaded over all of the rows.
So you will have to restructure a lot.

Furthermore the question theme "searchable dropdown" could be of interest.
[url] github.com/tpartner/LimeSurvey-Searchable-Dropdown [/url]
Try to install it.
Maybe I can include it into your layout.


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 7 months ago by Joffm.

Please Log in to join the conversation.

  • GiuliaDonati
  • GiuliaDonati's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 7 months ago #225560 by GiuliaDonati
Replied by GiuliaDonati on topic Array(Texts) with dropdown conditions
Thank you Joffm for all the help, I managed to implement all your suggestions ! Much appreciated and valued !!! :)

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose