Welcome, Guest
Username: Password: Remember me

TOPIC: Populate a dropdown list with data from external SQL database

Populate a dropdown list with data from external SQL database 1 year 2 months ago #95936

  • TarkiB
  • TarkiB's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
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: 1 year 2 months ago by TarkiB. Reason: Accidentally submitted early
The administrator has disabled public write access.

Populate a dropdown list with data from external SQL database 1 year 2 months ago #95944

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5302
  • Thank you received: 291
  • Karma: 247
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)limesurvey.org'"
The administrator has disabled public write access.
The following user(s) said Thank You: TarkiB

Populate a dropdown list with data from external SQL database 1 year 2 months ago #95953

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6240
  • Thank you received: 794
  • Karma: 238
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
The administrator has disabled public write access.
The following user(s) said Thank You: TarkiB
Moderators: ITEd
Time to create page: 0.151 seconds
Donation Image