Populate a dropdown list with data from external SQL database

More
3 years 10 months ago - 3 years 10 months ago #95936 by TarkiB
Hi there,

I'm just looking for a bit of guidance on this issue. I want to have dropdown lists populated with data from an SQL DB.

I'm speculating that I would need a script in the question that calls a PHP file which returns an array of data from the DB. I haven't been able to get this to work yet, however.

Is that the right track? Are there examples of this that I could look at?

I've been looking at this thread about using jQuery for autocomplete but it isn't quite what I'm after and I haven't been able to adapt it for my purposes.

Any help with this would be greatly appreciated.

Cheers.
Last Edit: 3 years 10 months ago by TarkiB. Reason: Accidentally submitted early

Please Log in to join the conversation.

More
3 years 10 months ago #95944 by Mazi
The problem is that usually such a list and the related HTML is created by Limesurvey on page load. That being said, I think the best approach is to have just one fixed answer like "I don't know" and then use some javaScript which on page load queries the database to get a list of answers. This can be done via Ajax.
Please also note that you need to assign a unique key to each answer. That is the answer code which will then be stored by Limesurvey.

A follow up problem will show up later when viewing or exporting the responses, because Limesurvey will search for the answer code at the Limesurvey database to query for the full answer string and this data will NOT exist if you load the list from an external DB.
So you should also consider updating the Limesurvey database with that data once a certain answer was selected by the user.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
The following user(s) said Thank You: TarkiB

Please Log in to join the conversation.

More
3 years 10 months ago #95953 by DenisChenu
Hello,

You have to use own php script to return json,

Look at the example in manual : manual.limesurvey.org/Workarounds:_Manip...wers_for_text_inputs

And look at the jquery.autocomplete example
jqueryui.com/autocomplete/#remote-jsonp

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
The following user(s) said Thank You: TarkiB

Please Log in to join the conversation.