Hi I hve a field called name_code with text autocomplete that use this sql sentence
SELECT code, name
FROM products
ORDER BY name
and this code on ajax on chenge event
$codigo = {name_code};
/**
* Check for an existing record
*/
// SQL statement parameters
$check_table = 'products'; // Table name
$check_where = "name = '". $codigo . "'"; // Where clause
// Check for record
$check_sql = 'SELECT *'
. ' FROM ' . $check_table
. ' WHERE ' . $check_where;
sc_select(dataset, $check_sql);
if (false == {dataset})
{
// Error while accessing database
}
elseif ({dataset}->EOF)
{
/**
* Display a message after an AJAX call
*/
// Javascript message parameters
$javascript_title = 'Error'; // Javascript message title
$javascript_message = 'El producto ingresado no existe!!'; // Javascript message contents
// Display javascript message
sc_ajax_message($javascript_message, $javascript_title);
}
else
{
sc_lookup(dataset,"select price from products
WHERE name = '{name_code}'");
if(!empty({dataset}[0][0])){
{unitprice} = {dataset}[0][0];
sc_set_focus('quantity');
}
else{
{unitprice} = 0;
sc_set_focus('unitprice');
}
}
Until now all good, the list of codes appears, and if I change the code by clicking in some of the code options, the price was changed.
But, If I don’t choose one of the options and I wirte a bad code, nothig happens, no message appears and if I write a correct ode, but no by clicking with the mouse, just writing, nothing happens either, the price doesn’t change.
What I doing wrong??
Thanks in advance,
Regards