Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: State/city quoestion

State/city quoestion 5 years 7 months ago #59865

  • Samba
  • Samba's Avatar
  • Offline
  • Junior Lime
  • Posts: 30
  • Karma: 0
Hi,

I need to have a dropdown list question with 2 drop down menus in one question one for states & one for the corresponding cities.

What is expected is that, when state "A" is selected, the city dropdown list should show only the list of corresponding cities of the state "A" and so on..

Currently I am using a dual array question which seems to give me the flexibility of having 2 dropdown lists but i cant figure out a way to address the issue of having only the corresponding cities of the selected state

I have seen this kind of functions mostly in Country/Province questions.

Any help would be appreciated..


Thanks in advance
Samba
The administrator has disabled public write access.

State/city quoestion 5 years 7 months ago #59881

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 6573
  • Thank you received: 1477
  • Karma: 579
Tricky...

I think you'll need to create your "State" dropdown and then use some JavaScript/Ajax to fire a PHP script that queries a database (or CSV file) to dynamically insert the "City" options depending on state selected. The JavaScript could then insert the selections from both dropdowns into hidden text inputs.

...very tricky

...unless Shnoulle or someone has an easier solution
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 7 months ago by tpartner.
The administrator has disabled public write access.

State/city quoestion 5 years 7 months ago #59911

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9586
  • Thank you received: 1375
  • Karma: 390
tpartner wrote:
...unless Shnoulle or someone has an easier solution
No , why me ?

I think the best is to use a jquery plugin like autocomplete
jqueryui.com/demos/autocomplete/

I think there are some workaround or forum post with some more information :)
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (use private message).
The administrator has disabled public write access.

State/city quoestion 5 years 7 months ago #60031

  • Samba
  • Samba's Avatar
  • Offline
  • Junior Lime
  • Posts: 30
  • Karma: 0
Hi,

So i managed to use the autocomplete plugin but now i'm not able to get my way around it working for me in multi text type question.

I'm pretty sure there must be a very easy solution (wich will probably expose my ignorance) :unsure: but i think i'll ask anyway.

So here is the deal, i need to have State & city in one question
2 dropdowns - dropdown list question with 2 drop down menus in one question one for states & one for the corresponding cities )

or

Two text fields with one giving auto complete options for states and the other for cities.

Thanks in advance.

PS - i used this http://docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Manipulating+a+survey+at+runtime+using+Javascript&structure=English+Instructions+for+LimeSurvey#Use_jQuery_Autocomplete_plugin_to_suggest_answers_for_text_inputs but I could only use the 1st method as the Demo csv mentioned there could not be downloaded



Regards,
Samba
The administrator has disabled public write access.

State/city quoestion 5 years 7 months ago #60032

  • holch
  • holch's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 5440
  • Thank you received: 813
  • Karma: 240
Hi Samba,

If I understand it right, you need the city question be shown dependent on the states question, right?

I would go for a 2 (or better said, various drop down lists) if you want to go out of the box. I am sure there is a way to make the list of cities dependend on the state question with Javascript, but this will require some Javascript skill that I don't have.

Unfortunately my solution requires, that you will have as many "city" questions as states. So in the case that you have a lot of states, you will have many city questions.

I would create the state question and then for each state a dropdown with the respective cities. The city questions will be shown/hidden via conditions depending on the choice of the state.

Tpartner might have a Javascript solution for you, though.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.

State/city quoestion 5 years 7 months ago #60033

  • holch
  • holch's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 5440
  • Thank you received: 813
  • Karma: 240
Ahhh, only saw just now that tpartner has already answered and finds it very "tricky". I remember a similar question (car model dependent on the car brand), but we used this in another survey tool, so this will probably not help. But it was pretty simple to administer. We had an excelsheet that basically created a list/array for the javascript.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.

State/city quoestion 5 years 7 months ago #60195

  • Samba
  • Samba's Avatar
  • Offline
  • Junior Lime
  • Posts: 30
  • Karma: 0
Hi,

I finally got around to use the autocomplete plugin in the Multi text question and it works all fine.

Now the problem is that since its a text question, it does not reflect in the statistics page.

Its important for us to know the location of the person answering the questions.

Is there a way where i can have the text inputs displayed in the statistics page?

Also is there any way to have question Full headings or Abbreviated headings in the Export results page instead of having question codes/ids in the choose coloums section?

As there are a lot of questions, while exporting, it is difficult to khow which questions are getting exported as we need to export data for different questions at different times.


Regards,
Samba
The administrator has disabled public write access.
Time to create page: 0.213 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form