Hi,
oke, here is the solution!
create one PHP file into your Joomla root and give him the name 'recordID' and insert this code:
<?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 id
FROM #__facileforms_records
WHERE id = (SELECT MAX(id) FROM #__facileforms_records)");
$recordid =$db->loadResult()+1;
echo ($recordid );
?>
then in your FORM GO to Advanced->More options -> Scripts->Init script and put this code:
function ff_mirkoExmaple111_init()
{
setInterval('test()',500):
} // ff_mirkoExmaple111_init
function test (){
jQuery.ajax({
type: "POST",
url: "<?php return JURI::root(true ); ?>/recordID.php",
data: test,
success: function(data) {
ff_getElementByName('hiddenElement').value=data;
}
});
}
-function ff_mirkoExmaple111_init() - instead 'mirkoExmaple111' insert name of your FORM
-ff_getElementByName('hiddenElement').value=data;
instead 'hiddenElement' insert name of hidden element.
it is all, please test this and let me know whether works!
If you have more questions, feel free to ask!
Regards,
Mirko