Bienvenue, Invité
Nom d'utilisateur : Mot de passe : Se souvenir de moi

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

Populate a dropdown list with data from external SQL database il y a 1 an 2 mois #95936

  • TarkiB
  • Portrait de TarkiB
  • Hors ligne
  • Fresh Lemon
  • Messages : 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.
Dernière édition: il y a 1 an 2 mois par TarkiB. Raison: Accidentally submitted early
L'administrateur a désactivé l'accès en écriture pour le public.

Populate a dropdown list with data from external SQL database il y a 1 an 2 mois #95944

  • Mazi
  • Portrait de Mazi
  • Hors ligne
  • LimeSurvey Team
  • Messages : 5300
  • Remerciements reçus 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'"
L'administrateur a désactivé l'accès en écriture pour le public.
Cet utilisateur a été remercié pour son message par: TarkiB

Populate a dropdown list with data from external SQL database il y a 1 an 2 mois #95953

  • DenisChenu
  • Portrait de DenisChenu
  • Hors ligne
  • Moderator Lime
  • Messages : 6198
  • Remerciements reçus 787
  • 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
L'administrateur a désactivé l'accès en écriture pour le public.
Cet utilisateur a été remercié pour son message par: TarkiB
Modérateurs: ITEd
Temps de génération de la page : 0.148 secondes
Donation Image