Hi,
in the example, we have two select list:
select list 1 - name-> customer
select list 2 - name -> modal
in the first select list, in Advanced of element scroll down to the section Action script select type custom, Action Change, and insert this code:
function ff_Customer_action(element, action)
{
switch (action) {
case 'change':
jQuery.ajax({
type: "POST",
url: "<?php return JURI::root(true ); ?>/Select_list_Customer_Model.php",
data: { code: ff_getElementByName('Customer').value},
success: function(data) {
var obj = JSON.parse(data);
var result = [];
var keys = Object.keys(obj);
keys.forEach(function(key){
result.push(obj[key]);
});
jQuery('#ff_elem370').empty();
jQuery('#ff_elem370').append(jQuery('<option>', {
value: '',
text: 'Choose option'
}));
for (var i = 0; i < result.length; i++) {
console.log(result[i]);
jQuery('#ff_elem370').append(jQuery('<option>', {
value: result[i],
text: result[i]
}));
}
}
});
break;
default:;
} // switch
} // ff_Customer_action
then I create one PHP file and please put this file into Joomla root, content of the PHP file is:
<?php
define('_JEXEC', 1);
if (file_exists(__DIR__ . '/defines.php'))
{
include_once _DIR_ . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', __DIR__);
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_BASE . '/includes/framework.php';
$db = JFactory::getDBO();
$code=$_POST['code']; // the value posted from the AJAX request above
$db = JFactory::getDBO();
$db->setQuery("Select Model From jos_Projects Where Customer = '$code' ");
$row =$db->loadColumn();
if(!$row){
echo "error";
} else {
echo json_encode($row);
}
?>
I do not in detail explain the code because as I see you understand the coding and I will let you that self try to do it on your FORM.
If you get to stuck, please let me know and I will help you!
Please download->unzip->and install it (BF->Configuration->Package Installer->select this xml file->Install Package).
Regards,
Mirko