Chained Selects lets you "chain" multiple select lists together so that the selection in a "parent" list can tailor the options available in a "child" list. Chained Selects supports unlimited unlimited number of "chains" in in a form.
In order to Create a chain select list you have to use the SQL Form Field and the fields will be loaded using AJAX JSON Calls.
The first option of a Chain select list can also be a Radio list.
SQLs used in this tutorial for Joomla 1.6+:
Getting Country and States from VirtueMart
Setting up the State:
- Go to the Custom Field Manager and Hit the new button;
- Select the SQL custom field type;
- Add the SQL query to the value field in order to create theStatedropdown;:
-
SELECT state_name AS text, state_id AS value
FROM #__vm_state
WHERE country_id = '{selectresult}'; - Set Use chain selectYes;
- Set Field to update to your City field; (in case you have a city database table)
- Select it's category;
- Save the custom field;
Setting up the Country:
- Go to the Custom Field Manager and Hit the new button;
- Select the SQL custom field type;
- Add the SQL query to the value field in order to create the Country dropdown:
-
SELECT country_name AS text, country_id AS value
FROM #__vm_country
WHERE 1; - Set Use chain select to Yes;
- Set Field to update to your state field;
- Select it's category;
- Save the custom field;
Example using Custom Values
Field You Prefer:
SELECT DISTINCT type AS text, type AS value
FROM #__ce_cv
WHERE published=1
ORDER BY type ASC
Field Select:
SELECT name AS text, value
FROM #__ce_cv
WHERE published=1 AND type='{selectresult}'
ORDER BY text ASC
SQLs used in this tutorial for Joomla 1.5:
Field You Prefer:
SELECT DISTINCT type AS text, type AS value
FROM #__contact_enhanced_cv
WHERE published=1
ORDER BY type ASC
Field Select:
SELECT text, value
FROM #__contact_enhanced_cv
WHERE published=1 AND type='{selectresult}'
ORDER BY text ASC
Recommend to a friend