Welcome to the LimeSurvey Community Forum

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

Show unique text according to user entry from table

  • TomTomT
  • TomTomT's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 2 months ago #225431 by TomTomT
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 3.25.6+201229
Own server or LimeSurvey hosting: Own server
Survey theme/template:
==================
Hello everyone,
I have to create a survey where if the user enters a specific entry (let's say a name and/or a birth date), it will show them a specific message from a predefined table (the table could include 1000 lines and 2 or 3 columns):
Example:
Table: [Peter, Jack, François];[Blue, Green, Red]
So if the user enters {Jack} it will show them {Your color is Green}
It has to be a survey because it will be part of a large survey on cognitive response.
Thanks in advance

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 2 months ago - 2 years 2 months ago #225440 by tpartner
This is a very broad question without any specifics.

- Where is the "message" data to be stored - hard-coded, CSV, remote database...?
- How do you expect the respondent to enter the selecting criteria - text input, list-radio...?
- Where do you want the output displayed?
- Do you need the output stored in the data?

So, my broad answer is yes, this can be done but it will require significant JavaScript and/or ExpressionScript development.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 2 years 2 months ago by tpartner.

Please Log in to join the conversation.

  • TomTomT
  • TomTomT's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 2 months ago #225441 by TomTomT
Thanks tpartner

- Where is the "message" data to be stored - hard-coded, CSV, remote database...?
Whatever is the easiest, so far it is in a csv file. I could use any source as long as the final purpose is met. I am looking for suggestions

- How do you expect the respondent to enter the selecting criteria - text input, list-radio...?
Both text input validation and date pick.

- Where do you want the output displayed?
Below or in the next step/question

- Do you need the output stored in the data?
No

I am not good in backend manipulation, I looked for some tutorials but i don't find anything that is from scratch
 

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 2 months ago - 2 years 2 months ago #225449 by tpartner
As I said, this will require significant JavaScript development, out of the scope of this forum.

Whatever is the easiest, so far it is in a csv file. I could use any source as long as the final purpose is met.

Use jQuery.csv to pull in the CSV content and create an array of arrays.
- github.com/evanplaice/jquery-csv

Both text input validation and date pick.

Place listeners on the survey elements:
- Date picker: dp.change event - getdatepicker.com/4/Events/#dpchange
- Text input: jQuery on('keyup') event - api.jquery.com/on/

Below or in the next step/question

Use jQuery to dynamically update the text of elements - api.jquery.com/text/

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 2 years 2 months ago by tpartner.
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 2 months ago - 2 years 2 months ago #225454 by Joffm
I can offer an easy solution, though I do not know if it covers all your requirements.
Create a well defined relation table like this
Jack      Blue      
John      Yellow    
Alice     Red       
Michael   Blue      
Hugo      Pink      
Roger     Green     
Name7     Color7    
Name8     Color8    
Name9     Color9    
Name10    Color10   

Each name has the same length (right padded) and the colors also have the same length.
This you use as default answers in a (hidden) question of type "huge text". (Q0)

Now after entering a name in an question of type "short text" (Q1) you find it with the function "strpos" and can capture the entire row with function "substr", as you know the length.
You get something like
"Roger     Green     "
Again with "substr" you capture the color; you know that it starts at column 11.

In total you can use this equation
{substr(substr(Q0,strpos(Q0,Q1),20),10)}




I entered 1000 lines, no problem.
   


Disadvantage: The equation has to be on the next page.

The same should be possible with a date.

Of course you can adapt to longer text, to more than one attribute of John, Jack, Namcy or Clarence.

I am aware that a javascript solution will be more elegant, but unfortunately I am not able to write one line of javascript code.

Joffm
 

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

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose