Welcome to the LimeSurvey Community Forum

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

Pre-fill answer based on previous answer

  • bsisurvey
  • bsisurvey's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 days 14 hours ago #268470 by bsisurvey
Pre-fill answer based on previous answer was created by bsisurvey
(Write here your question/remark)
Please help us help you and fill where relevant:
Your LimeSurvey version: 3.19.1+191009
Own server or LimeSurvey hosting: Own server
Survey theme/template:
==================
How to pre-fill answers based on previous questions? The scenario:
Q1.a - what is the company code?
           C001

Q2.b - Company name
           "test name" (pre-fill the answer based on the code on the previous answer)

Thanks.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 days 5 hours ago #268472 by Joffm
Replied by Joffm on topic Pre-fill answer based on previous answer
Hi,
there are several ways.
Unfortunately you did not explain what for you want to do this.
Only to display the "company name" in later questions? Or as an answer iption in later questions? Or...?

1. Well, the first solution with only ExpressionScript.
Create a (hidden) question of type "long text" as your pool (QPool).
Here you enter the Company No. and Name in a well defined format, like this
 

After entering the number in Q1 you grab the name with something like this
{trim(substr(QPool,strpos(QPool,Q1)+6,50))}
 
 

The hashtag at the beginning of each line is to avoid an index of "0" which also means "not found"

2. And here the solution with the plugin "autocomplete" which is included in LimeSurvey.
In the "plugin/autocomplete" folder of your installation you find many demos.
More here where I think the Ceos-Demo the best for you
[url] gitlab.com/SondagesPro/QuestionSettingsType/autoComplete [/url]
 

Joffm



 

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

Please Log in to join the conversation.

  • bsisurvey
  • bsisurvey's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 day 9 hours ago - 1 day 9 hours ago #268495 by bsisurvey
Replied by bsisurvey on topic Pre-fill answer based on previous answer
Hi Joffm,

Thanks for the information.

Apologies for the confusion. It is to display the "company name" automatically which is associated with the company code answered on the Company Ref. no question. Example as attached.

It doesn't have to be displayed in a question/answer format. Displaying the text "Company Name: Test Company" would be sufficient.

Thanks
Attachments:
Last edit: 1 day 9 hours ago by bsisurvey. Reason: adding attachment

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 day 3 hours ago #268516 by Joffm
Replied by Joffm on topic Pre-fill answer based on previous answer
Hi,
the screenshot shows two questions of type "short text", but you say you only want to display the name.
Well,
you can use both solutions.
1. in the the first - the "long text" question as "company pool" you can display the name with string functions
{trim(substr(QPool,strpos(QPool,Q1)+6,50))}
(Adjust to your needs (length of company no, length of company names.)

2. Here is the result - the company name - is entered in a question of type "short text" by default.
You can hide this question with css class "hidden" and use ExpressionScript to display its content.
Like this
At the start
 

after entering a number
 

Remark: This autocomplete becomes really slow if there are more than 500 elements.

Now start to create a prototype and if there are further questions, send the lss export of what you created so far.

Joffm
 

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

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 day 3 hours ago #268517 by holch
Replied by holch on topic Pre-fill answer based on previous answer
Off-topic:

Your LimeSurvey version: 3.19.1+191009


Eure Limesurvey-Installation ist jetzt über 5 Jahre alt und hat seit dem 09.10.2019 kein Update, keine Bug Fixes, keine Security Patches mehr bekommen. Zudem ist LS 3.x jetzt schon einige Zeit EOL. Ihr solltet wirklich über ein Update nachdenken.

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.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose