I've been searching the internet over this one for days now and am even more confused, so I hope you can point me in the right direction. I am basically trying to create a 3 tier cascading dropdown based on country/city/states.
I'm using the following code to create a the second (states) drop down list in a form
This works fine when i am hand coding the array items, but I am totally lost on how to assign table fields instead. At the moment I am manually looking at my datable tables for country, city and state and matching the IDs to the array items, which is frankly ridiculous and will take forever. So I need to change `
parent_array['1'] = ['1|item 1','2|item 2'];
to something like..
parent_array['1'] = ['fieldID'],['fieldName'];
of course this doesn't work, and I am guessing its not as simple as that, as i obviously need something like an SQL query for it to work off, but I'm not sure what I need to do to get started.
Can anyone point me in the right direction to get this second cascading dropdown to change to the right states when a country is selected.
Thanks very much in advance