Auto complete value in textbox

Hi,

​I have a tableA consist of name, address, age.

​I have another tableB consist of name, address, age and more fields.
​I create a form using tableB, the name is using Text Auto-Complete. When the name entered can be search from tableA, I need to auto display the value for address and age, user can change if needed since it is a textbox.

​I tried putting the following under Ajax event > name onChange but it does not work. Can anyone kindly help? Thanks.
sc_select(dataset, “select * from tableA where name =’{name}’”);
if (false == {dataset})
{
// Error while accessing database
}
elseif ({dataset}->EOF)
{
// No record found
}
else
{
// Record found
{address}={dataset}->fields(‘address’);
{age}={dataset}->fields(‘age’);

}

Try this:

// Check for record
sc_lookup(dataset,“SELECT address, age FROM tableA
WHERE name = ‘{name}’”);

if(!empty({dataset}[0][0])){

{address} = {dataset}[0][0];
{age} = {dataset}[0][1];

}

else{

{address} = "";
{age} = "";

}