Welcome to the LimeSurvey Community Forum

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

autocomplete only in one column of an array (text) question

  • squidy
  • squidy's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 6 months ago - 1 year 6 months ago #245419 by squidy
Please help us help you and fill where relevant:
Your LimeSurvey version: 5.3.32
Own server or LimeSurvey hosting: Own server
Survey theme/template: fruity
==================
Hello..
I'm using Denis Chenu's autoComplete plugin ( github.com/SondagesPro/LS-autoComplete ) and would like to know if I can apply this to just one column of an array (text) question.

I'm using a workaround to create a "dynamic" array to add or remove rows as well. So I've attached an image of the question and the .lss file.

 

It's possible? Can you help me?
 

Using LS 5.x
Last edit: 1 year 6 months ago by squidy.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago - 1 year 6 months ago #245422 by Joffm
Hi, I do not know, because I do not use it. It gets really slow if there are more than 1000 rows in the file.

But you may use this
Code:
<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" />
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/1.0.11/jquery.csv.min.js"></script>
 
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:complete',function() {
    // Hier wird der Speicherort der Datei angegeben
    var url = "/upload/surveys/{SID}/files/namen.csv";
 
    var Names = new Array();
 
    $.get(url,function(data){
      fullArray = $.csv.toArrays(data);
      $(fullArray).each(function(i, item){
        Names.push(item[0]);
      });
      $('#question{QID} .answer-item:nth-child(2) input[type="text"]').autocomplete({
        minLength: 2,
        source: Names
      });
    });
  });
</script>

 

 Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 6 months ago by Joffm.

Please Log in to join the conversation.

  • squidy
  • squidy's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 6 months ago #245426 by squidy
Thanks for answering, Joffm.

I have a question called PRODUTO before the question ITENS that has a list of answers with code at the beginning. Take a look:

List of answer of the question PRODUTO
ARCE01.01.01 - Answer produto 01
ARCE01.01.02 - Answer produto 02
ARVI01.02.01 - Answer produto 03
ARVI01.02.02 - Answer produto 04
ARVI03.01.01 - Answer produto 05
(...)

List of answer of the question ITENS (csv)
ARCE01.01.01.01 - Answer item 01
ARCE01.01.01.02 - Answer item 02
ARCE01.01.01.03 - Answer item 03
ARCE01.01.02.01 - Answer item 04
ARCE01.01.02.02 - Answer item 05
ARVI01.02.01.01 - Answer item 06
ARVI01.01.01.01 - Answer item 07
(...)

I need to filter the csv output based on this code... For example: If the user selects ARCE01.01.01 - BLA BLA BLA in the question PRODUTO, the question ITENS will only show entries that start with ARCE01.01.01.

Is this possible?

Using LS 5.x

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago - 1 year 6 months ago #245428 by Joffm
This is a different question, isn't it?
You didn't mention anything about it before.

At least you should provide a lss export of your survey (only the relevant questions)
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 6 months ago by Joffm.

Please Log in to join the conversation.

  • squidy
  • squidy's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 6 months ago #245430 by squidy
Sorry Joffm.. I didn't mention this before because I was using Denis Chenu's autoComplete plugin which does this filter.. Now using your suggestion I can't figure out how to filter based on the previous answer code...

Need to open another one topic?

Using LS 5.x

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago - 1 year 6 months ago #245432 by Joffm
PRODUTO is of type "short text"?
How do you will be able to compare?
The participant may use different spelling.

In my opinion it should be a list(radio), or?
An easy solution would be to use different csv files according to PRODUTO, like
"items1.csv", "items2.csv",...
and access them by "items{PRODUTO}.csv"

Of course you can't display - what you seem to want - "all on one page". This is the worst of all in an online survey.

Example:
Produto = 1
 
Produto = 2
 

You see: Different names appear

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 6 months ago by Joffm.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose