Skip to Content Skip to Menu

cascaded drop down select with jquery ajax,php and mysql

9 years 8 months ago #259336 by globalgridfree
how would you achieve a cascaded drop down select with jquery ajax,php and mysql work?

example, country, state/prov, city.

when user picks the "country", then the provinces/states of the "country" selected are only visible, same with city once province selected.

I would be using a database that has gps co ordinates for future map additions,

from what i understand, 3 new database entries are needed,country,state,city.

do i need 3 new field types? i would like all 3 fields visible and searchable.

3 separate query's?
thanks

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8282
  • Karma: 1443
9 years 8 months ago #259416 by krileon
We don't have anything to provide such a combo. You'd need to develop a new fieldtype plugin from the ground up for that. Best I can suggest is forget the ajax loading and use CB Conditional and CB Query Field to show state after country is selected then zip after state is selected. You'd use a query select type field to output countries and states from a database table. We've a tutorial for this usage, which you can find below.

www.joomlapolis.com/support/tutorials/107-use-cases/18377-configuring-a-country-field-with-cb-query-field-plugin


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: globalgridfree

Please Log in or Create an account to join the conversation.

9 years 8 months ago #259648 by globalgridfree
what would be the selector for the previous field?

this is my query for the province and state without a selector from the country field.

SELECT `name`, `country`, 'country' FROM `regions` ORDER BY name, country

this is what i have for the country

SELECT `name`, `code`, 'code' FROM `countries` ORDER BY name, code

I am not sure what the third selector is for after select SELECT `name`, `code`, 'code'

I am new to sql but i am learning it any help appreciated

also using the conditional tab

I been playing with different setting, it seems with the query drop down single select when country selected the condition to show after country is no longer empty does not show up, i would imagine if it was moved to the next tab it would activate the province selector. i have not tried this yet.
is there a cheat sheet for the conditional tab functions?
thanks

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8282
  • Karma: 1443
9 years 8 months ago #259683 by krileon
You won't be checking for the previous field in the query. You'll separate them by an optgroup as shown in the tutorial linked above. If you include the previous field in the query it will not take affect until the page refreshes as again there is no ajax feature like you're wanting.

To test that it's not empty do a conditional self to check that the previous field is not empty and if it isn't then show. Conditional tab and conditional field self work exactly the same. Conditional field others is the exception as it's different parsing.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

9 years 8 months ago #259931 by globalgridfree
i am trying to achieve a simple county/state/city with the suggested set up, it seems like the database queries are high with this set up. is there anyway to stream line this process to not be such a resource hog?

if the website community bases everything on the location of the member, to reduce queries and server load, this is the area that would require optimization the most.

my main problem is the amount of request made once the country field is turned on, if i turn on all 3 fields the server crashes.

any ideas would be greatly appreciated

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8282
  • Karma: 1443
9 years 8 months ago #259960 by krileon
Depends on how many entries you have in your tables. Ideally you'd want to optimize the table with indexes to speed up access.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: globalgridfree

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum