Skip to Content Skip to Menu

Create a drop down Regions - Provinces - City

  • AchLive
  • AchLive
  • OFFLINE
  • Posts: 253
  • Thanks: 14
  • Karma: 3
9 years 10 months ago #255827 by AchLive
Hello, I created fields Query Drop Down (single select) connected to the tables included in Db.
On a table there is the list of the regions, in another table I have included a list of the provinces, in another table I have included a list of cities.
I want that when the first field you select a region in the second next field were displayed provinces corrispondentio and then selecting the province were selected municipalities. The tables have fields connection.
Think you can do using the Plugin CB Query Field in conjunction with CB Conditional. Or do you have any suggestions for what I asked.
Unfortunately, the evidence that I did not I have a good result.
Thanks for the support.

Joomla 3.3.6
CB 2.0.4
CB Query Field 4.0.3
CB Conditional 4.0.4

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

  • heyai
  • heyai
  • OFFLINE
  • Posts: 324
  • Thanks: 79
  • Karma: 24
9 years 10 months ago #255845 by heyai

hey-ai - the community for asian guys and non-asian girls

The search bar is your friend, not just decoration!

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

  • AchLive
  • AchLive
  • OFFLINE
  • Posts: 253
  • Thanks: 14
  • Karma: 3
9 years 10 months ago #255858 by AchLive
Replied by AchLive on topic Create a drop down Regions - Provinces - City
Heyai Hi, thanks for your reply.
I try to explain the scenario.
I have three tables in the db:
- The first table contains the Italian regions, table name "tbregioni";
- The second table contains the Italian provinces, table name "tbprovince";
- The third table contains the Italian municipalities, table name "tbcomuni".
The three tables have link fields.Watch img Table_Structure.



The result I want to achieve in the registration form and change user profile is that the user select the region from the field of type Query Drop Down (Single Select) and the next field always Query Drop Down (Single Select) displays the corresponding provinces.
I put the stamp of the first field that works, certainly the wrong query on the second. I can not get the right filter.



Thank you for your support and take this opportunity to wish for the new year
Attachments:

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48482
  • Thanks: 8283
  • Karma: 1443
9 years 10 months ago #255873 by krileon
Replied by krileon on topic Create a drop down Regions - Provinces - City
If you want to condition the provinces based off the region selected it won't be doable. The Query Drop Down (Single Select) fieldtype pulls its option values from a database query and not from CBs internal table so you will not be able to condition those options. The best you could do is show the Province field when the Region field has a value of any kind selected. Same for City after a Region has been selected. Example of how to show/hide fields using CB Conditionals can be found below.

www.joomlapolis.com/support/tutorials/107-use-cases/18336-using-cb-conditionals-to-hide-or-show-fields-or-tabs

You also can't have the query dynamically update the options of a list based off another fields value. It will take an entire page load for that dropdown to update if you do that. So you're better off having the query display all Regions separated by Province using the optgroup feature.

Your second image has way too much compression and am unable to read the query you're trying to use so I can't advise as to why it isn't working.


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.

  • AchLive
  • AchLive
  • OFFLINE
  • Posts: 253
  • Thanks: 14
  • Karma: 3
9 years 10 months ago - 9 years 10 months ago #255894 by AchLive
Replied by AchLive on topic Create a drop down Regions - Provinces - City
Hi Krileon, thanks for your reply.
I want to create a query for the second field (province) which depends on the value of the first field (Region) etc .. I can not do this because they are not very practical for mysql and from what you've written it seems that you can not do .
Can I use CB Conditional to display or not display the field province affected to a value of the field region, this is fine, but when I view the field province can not filter its content, which comes from the DB table, according to what I have typed in the field region.
I read a post it should do more or less what I'm looking for another type of field.
To me it would be okay.
I tried to create the field cb_regioni type text in integration I set this query
Code:
SELECT `codiceistat_regione` FROM `tbregioni` WHERE `nome_regione` = '[value]'
and it works well.
I created the second field cb_provincia type text, in additions I set this query
Code:
SELECT `nome_provincia` FROM `tbprovince` WHERE `codiceistatregione_provincia` = 'codiceistat_regione'
but it does not work.
Can you tell me where am I wrong?
Obviously the two fields
Query Validation Enabled;
Validate On Successful;
Results Ajax Validation Enabled.
Last edit: 9 years 10 months ago by AchLive.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48482
  • Thanks: 8283
  • Karma: 1443
9 years 10 months ago - 9 years 10 months ago #255898 by krileon
Replied by krileon on topic Create a drop down Regions - Provinces - City

I want to create a query for the second field (province) which depends on the value of the first field (Region) etc .. I can not do this because they are not very practical for mysql and from what you've written it seems that you can not do .

That's doable, but like I explained above it will not update the Provinces when you change the Region until the page has been reloaded. This will be 100% non-functional on registration and be completely awkward for profile edit. At any rate it's done with the below.

Code:
SELECT `nome_provincia` FROM `tbprovince` WHERE `codiceistatregione_provincia` = '[cb_regioni]'

I only speak English so I have no idea what those columns even mean, but I assume codiceistatregione_provincia is the Region for the province. In which case you'd make sure it's equal to your Region field value, which is added in using a substitution.

but it does not work.
Can you tell me where am I wrong?
Obviously the two fields
Query Validation Enabled;
Validate On Successful;
Results Ajax Validation Enabled.

I don't understand why you're using query validation. I'm at a total loss as to what you're trying to do now, sorry. Query validation just takes the value of the field and compares it to a database query to see if the value is valid.

I was under the impression you wanted to generate a Select list of Provinces, Regions, and Cities with their options being based off the previous input. This is done using Query Drop Down (Single Select) fieldtypes, not query validation.


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.
Last edit: 9 years 10 months ago by krileon.

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

Moderators: beatnantkrileon
Powered by Kunena Forum