Welcome, Guest
Username: Password: Remember me

TOPIC: State/city quoestion

State/city quoestion 3 years 6 months ago #59865

  • Samba
  • Samba's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • 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.

Re: State/city quoestion 3 years 6 months ago #59881

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4272
  • Thank you received: 806
  • Karma: 369
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 3 years 6 months ago by tpartner.
The administrator has disabled public write access.

Re: State/city quoestion 3 years 6 months ago #59911

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6451
  • Thank you received: 844
  • Karma: 249
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 :)
The administrator has disabled public write access.

Re: State/city quoestion 3 years 5 months ago #60031

  • Samba
  • Samba's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • 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.

Re: State/city quoestion 3 years 5 months ago #60032

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2851
  • Thank you received: 359
  • Karma: 124
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 | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Re: State/city quoestion 3 years 5 months ago #60033

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2851
  • Thank you received: 359
  • Karma: 124
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 | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Re: State/city quoestion 3 years 5 months ago #60195

  • Samba
  • Samba's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • 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.
Moderators: ITEd
Time to create page: 0.119 seconds
Donation Image