<?php
function sumar($a,$b) {
return $a + $b;
}
function multiplicar($a,$b) {
$r = $a * $b;
$html = new gHtml;
$html->alert("This example also shows how to use gHttp");
/* Keep show the result in result2 */
$html->setObject('result2');
$html->setProperty('innerHTML',$r);
$html->alert("result2 now was changed");
/* The result is also the new size of the HTML object with id ID*/
$html->setObject('id');
$html->setProperty('rows', $r);
$html->setProperty('value',"Long's text\ncesar");
$html->alert("now the value rows");
/* Return the result also to the default function */
$html->alert("now the value is returned, if there is a function that get the return, it will be changed");
return $r;
}
include("class/gajax.php");
include("class/gajax.prototype.php");
$ajax = new gAjax('js/');
$ajax->export("sumar");
$ajax->export("multiplicar");
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cesar Rodas</title>
</head>
<body>
Calling the PHP function sumar(5,10) = <span id="result"></span>
<?php
$ajax->execute("result","sumar",5, 10);
?>
<form>
A=<input type="text" id="a" /><br />
B=<input type="text" id="b" /><br />
AxB = <span id="result1"> (normal)</span><br />
AxB = <span id="result2"> (gHttp)</span><br />
<input type="button" onclick="<? $ajax->execute('result1',false,"multiplicar",byvalue('a','value'), byvalue('b','value') );?>" value="Multiplicar!" /><br />
<textarea id = 'id' cols=40 rows=10></textarea>
</form>
</body>
</html>
|