Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

CB Query Field 3.0 - Configuring the Value based on the value of another field

  • jminer
  • jminer
  • OFFLINE
  • Posts: 18
  • Thanks: 1
  • Karma: 0
11 years 3 months ago #231284 by jminer
I am currently designing a registration page for my users.
The registration page has these following fields -
1. School State
2. School County
3. School District.
4. School Name

There are 10,000's of data for each field.
For example there will be 26 states, each state will have around 50 county and then 1000 of district and 10000 of school per district.

I need to filter the values based on the value selected before.

So if a person selects California as their state then it should display on the county that are there in California.

I am using CB Query field 3.0

I have the table with all these data.

1st drop down i.e. School State
Name - cb_schoolstate
query -SELECT DISTINCT state FROM `school_data` order by state

2nd drop down i.e. School County
Name - cb_schoolcounty
query - SELECT DISTINCT county_name FROM `school_data` where state='[cb_schoolstate]' order by county_name

but this second drop down is not populating any result.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
11 years 3 months ago #231299 by krileon
That will only work if you edit State, save, edit County, save. There is no Ajax based updating on the query fields options that would kill most sites to constantly Ajax update a field and run a database query every update.

You can use CB Conditional to show/hide fields/tabs if you need to condition things together, but that's going to require multiple sets of fields.

Your best option is to set the optgroup for County to state and order by state then order by county_name so they're separated by state.


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.

  • jminer
  • jminer
  • OFFLINE
  • Posts: 18
  • Thanks: 1
  • Karma: 0
11 years 3 months ago #231353 by jminer
Thanks,

Is there any custom code plugin where I can code this using ajax and php?
Or is there any other solution rather than using conditional plugin as in this case i have to create 10 of thousands of condition..

J

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
11 years 3 months ago - 11 years 3 months ago #231354 by krileon

Is there any custom code plugin where I can code this using ajax and php?

No, you'd need to develop such a usage. Shouldn't be too hard to use the fieldClass function like CB Core Fields Ajax does and replace the HTML display. It's not a lightweight thing though and it is a DOM replacement so you risk losing jQuery bindings if they're not designed to handle rebinds.

Or is there any other solution rather than using conditional plugin as in this case i have to create 10 of thousands of condition..

Use the Group Column parameter. This way the state is grouped by Country. This usage is shown in our tutorial 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.
Last edit: 11 years 3 months ago by krileon.

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

  • jminer
  • jminer
  • OFFLINE
  • Posts: 18
  • Thanks: 1
  • Karma: 0
11 years 3 months ago #231386 by jminer
But we have more than 50,000 school, it would not be good for a user to be presented with such a long list.

I was hoping that the user can narrow down that list using state, county and district filter.

Any advice?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
11 years 3 months ago - 11 years 3 months ago #231395 by krileon

But we have more than 50,000 school, it would not be good for a user to be presented with such a long list.

I don't know what to tell you then. You could try adding jQuery to profile edit using CB Auto Actions and change the dropdown to a Select2 dropdown, which has a search feature. It's the same plugin used for the Triggers dropdown in CB Auto Actions.

ivaynberg.github.io/select2/

I was hoping that the user can narrow down that list using state, county and district filter.

You can, but it's going to take a page load so the query adjusts.

Any advice?

You'd need to develop a plugin to do what you're wanting. We have nothing that reloads the HTML edit display of a field. However if you implemented such a thing you risk losing a lot of jQuery bindings as a few plugins are probably not using live, on, or delegate. Probably best solution would be an ajax populated select field that you could force an ajax call for and it only changes its options and nothing else so the DOM could stay intact (basically a remote data populated dropdown that refreshes in intervals, etc..).


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: 11 years 3 months ago by krileon.

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

Moderators: beatnantkrileon
Powered by Kunena Forum