× If you expect answers you should describe your problem and give as much information's as possible. (SQL-Structure, Template Code, Joomla Version ...) Please read this before posting: joodb.feenders.de/support.html

Dropdown search field + dynamic code

More
8 years 7 months ago #3532 by admin.cardet
Dropdown search field + dynamic code was created by admin.cardet
Hi,

I want to create a drop down search field, for instance Countries (the information will be gathered in another table) and based on the user selection then a new drop down search field will appear that has all the cities for the country selected by the user.

thank you in advance
Christiana

Please Log in to join the conversation.

More
8 years 7 months ago #3538 by Dirk
Replied by Dirk on topic Dropdown search field + dynamic code
If you just want to display a select field with all possible values in a column you can use the {joodb groupselect} function.

If you want just custom search terms you must write a plugin and load it into
/components/com_joodb/plugins/PLUGINNAME.php

Example for countries.php
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
 $db = $this->joobase->getTableDbo();
 $db->setquery("SELECT `name` FROM `countries` ORDER BY `name` ASC");
    if ($slist = $db->loadCollumn()) {
        $output .=  '<select name="search">';
        foreach ($slist AS $var => $val) {
            $output .= '<option ';
            if ($val==$this->params->get('search')) $output .= ' selected="selected"';
            $output .= '>'.$val.'</option>';
        }
        $output .=  '</select>';
    }
}
The following user(s) said Thank You: admin.cardet

Please Log in to join the conversation.

Moderators: Dirkjoest