Populating two dependent combos

48 views
Skip to first unread message

Fran M.

unread,
Feb 9, 2012, 8:43:23 AM2/9/12
to Joomla! General Development
Hi,
I want to have 2 dependent combox in the frontend. One of them must be
populated from the joomla database depending on the option selected on
the other combo.
Anybody knows how to do that?

Thanks

PS: The examples I have found call a PHP file directly with AJAX, but
I dont know how to do that using the joomla framework.

Geoff Ellison

unread,
Feb 10, 2012, 6:09:33 AM2/10/12
to Joomla! General Development
I once did something similar, without AJAX. The basic steps were:
1. load your required data in the back-end in PHP
2. output to your page as javascript arrays
3. attach an onChange function to the first dropdown
4. populate the 2nd dropdown from the array data, based on the 1st
selection.

If you have heaps of data, you should probably use AJAX, and I suggest
you use JQuery libraries in that case. But if there is not too much
data, this approach works nice and fast.

I googled "javascript cascading dropdown example" and found this
example: http://www.trans4mind.com/personal_development/JavaScript/tripleMenu.htm

Geoff.
Reply all
Reply to author
Forward
0 new messages