Hello,
could you please navigate in your 'Radio button field' then Go Advanced -> In Actionscript select type 'Change' and into code box insert code below:
(This is an example for radio buttons with 3 values (values1, value2, value3) and when you click on one of the offered radio buttons, the field 'total' will display how much record has that selected radio button in the database).
function ff_radiogroup_action(element, action)
{
switch (action) {
case 'change':
ff_test1_action(element, action);
ff_test2_action(element, action);
ff_test3_action(element, action);
break;
default:;
} // switch
} // ff_radiogroup_action
// First function for values1
function ff_test1_action(element, action) //where radioelem is the name of the radio group
{
switch (action)
{
case 'change':
vals = '';
jQuery.ajax({
type: 'GET',
url: '<?php return JURI::root(true ); ?>/value.php ',
data: 'test',
success: function(data){
opts = JQuery("[name=\"ff_nm_radiogroup[]\"]");
for (o = 0; o < opts.length; o++)
if (opts[o].checked)
{
vals = opts[o].value;
}
if (vals=="value1") // here you can add further dependencies
{
return ff_getElementByName('text').value = data;
}
}
});
break;
default:;
}
}
// Seconds function for values2
function ff_test2_action(element, action) //where radioelem is the name of the radio group
{
switch (action)
{
case 'change':
vals = '';
jQuery.ajax({
type: 'GET',
url: '<?php return JURI::root(true ); ?>/value1.php ',
data: 'test',
success: function(data){
opts = JQuery("[name=\"ff_nm_radiogroup[]\"]");
for (o = 0; o < opts.length; o++)
if (opts[o].checked)
{
vals = opts[o].value;
}
if (vals=="value2") // here you can add further dependencies
{
return ff_getElementByName('text').value = data;
}
}
});
break;
default:;
}
}
//Third function for values3
function ff_test3_action(element, action) //where radioelem is the name of the radio group
{
switch (action)
{
case 'change':
vals = '';
jQuery.ajax({
type: 'GET',
url: '<?php return JURI::root(true ); ?>/value2.php ',
data: 'test',
success: function(data){
opts = JQuery("[name=\"ff_nm_radiogroup[]\"]");
for (o = 0; o < opts.length; o++)
if (opts[o].checked)
{
vals = opts[o].value;
}
if (vals=="value3") // here you can add further dependencies
{
return ff_getElementByName('text').value = data;
}
}
});
break;
default:;
}
}
Then, in your server (joomla root) make three PHP files with a different name (in this case, 'value1', 'value2', 'value3 ') which you will be insert into JS code (On this line kode : url: '<?php return JURI::root(true ); ?>/value1.php ',).
In all PHP files input this code:
<?php
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/' ));
require_once ( JPATH_BASE .'/includes/defines.php' );
require_once ( JPATH_BASE .'/includes/framework.php' );
$db = JFactory::getDBO();
$db->setQuery('SELECT Count(*) FROM `wlrak_facileforms_subrecords` WHERE value="Value1"');
$result = $db->loadResult()+1;
echo json_encode($result);
?>
Please, in PHP code replace the condition in SQL query 'where value="" ' for search different values of a selected radio button.
In attach file I sent to you may test example. Please download->unzip->and install it (BF->Configuration->Package Installer->select this xml file->Install Package).
regards!
Mirko