command = "ahah_test";
$result->params =
"a=" . urlencode($textA->content) .
"&b=" . urlencode($textB->content);
return "HANDLED"; // Could return array("REDIRECT",url)
}
function JS_add ($component) {
global $backendURL,$textA,$textB,$result;
?>
/* We fetch the test backend script that adds two numbers, with a GET, and put the result into the div with id "target" */
var a = js_content () ?>;
var b = js_content () ?>;
js_ahah ("'$backendURL'","'ahah_test'","'a=' + a + '&b=' + b","'GET'");
}
/* We implement the multiply button client-side where possible, and server-side when we fall back.
Do this where possible. */
function FALLBACK_multiply ($component) {
global $textA,$textB,$result;
$result->command = false;
$result->set_html ("Result: " . (intval($textA->content) * intval($textB->content)) . "");
return "HANDLED";
}
function JS_multiply ($component) {
global $textA,$textB,$result;
?>
/* We fetch the test backend script that adds two numbers, with a GET, and put the result into the div with id "target" */
var a = js_content () ?>;
var b = js_content () ?>;
js_set_html ("'Result: ' + a*b + ''");
}
/* We implement the subtract button server-side all the time - eg, if it needed to be able to redirect the page */
function FALLBACK_subtract ($component) {
global $textA,$textB,$result;
$result->command = false;
$result->set_html ("Result: " . (intval($textA->content) - intval($textB->content)) . "");
return "HANDLED";
}
?>