Topic: How to set javascript value?

I am new to xajax, and had a question.  I need to return the value from the PHP code to javascript, so I can notify the user accordingly. 

Here is the code snippet of the PHP and JS

/**** PHP *****/
function check_empTravel($eid, $tdate) {

    $xres = new xajaxResponse();

    $q = "SELECT COUNT(*) FROM otl_emptravels " .
            "WHERE emp_id={$eid} " .
            "AND date='{$tdate}'";
    $cnt = db_get_first($q);

    if(!$cnt) {
      // set variable that no records were found

    }
    else {
     // set variable that record was found

    }

    return $xres;
}

/**** JS Code *****/
function check_empTravel(eId, tDate) {
    xajax_check_empTravel(eId, tDate);
}

I need to access the count of records from the otl_emptravels table.  How do I pass the value to JS from the $xres object?
Thanks
- Artee

Re: How to set javascript value?

Hi,

Use the response call method.

$response->call('functionName', argument[,argument,...]);

You can alsouse the script method.

$response->script('myfunction(1)');

$response->script('myfunction(0)');
If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: How to set javascript value?

Thanks Ed Robinson.  The response->call method was the one I was looking for. 

I couldn't find much documentation for all the xajax methods available.  Is there a site that you could refer me to?

Re: How to set javascript value?

Try here: http://www.xajax-project.org/

You might also try looking at the source code. It is very well commented. The forums also have loads of examples.

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.