<html>
<head>
<style type="text/css" rel="stylesheet">
div {
border-style:solid;
border-width:1px;
border-color:black;
}
</style>
<script LANGUAGE="JavaScript" src="js/tkajax.js" type="text/javascript" ></script>
<script LANGUAGE="JavaScript" src="js/JSON.js" type="text/javascript"></script>
<script language="javascript">
function teste() {
if ( document.getElementById( 'id_contato' ).value.length == 0 ) return;
_ajaxobject = new TKAjax();
_ajaxfilter = new AjaxFilter();
// md5 query
sql = "1:afe8133bd534f4a04e1222c913b735f7";
_ajaxfilter.addFilter( "id_contato", document.getElementById( 'id_contato' ).value, _ajaxfilter.NUMERIC );
_ajaxfilter.addResult( "nm_contato" );
_ajaxfilter.addResult( "telefone" );
_ajaxfilter.setSql( sql );
_ajaxobject.setJSONData( _ajaxfilter );
_ajaxobject.setServerScript( "Controller.php" );
// setting the global callbackresult variable to customized requestListener function
// which will be used by AjaxResultManager
_ajaxcallbackresult = requestListener;
// object to treat callback result manager
result = new AjaxResultManager();
_ajaxobject.setProcessReq( result.getCallback() );
_ajaxobject.sendDataToServer( 'cd_terceiro=9999' );
};
function requestListener() {
if ( _ajaxresultjsontext[ 0 ] == "error" ) {
alert( _ajaxresultjsontext[ 1 ] );
// ajaxfilter created at function sendRequest
res = _ajaxfilter.getResults();
for ( i = 0; i < res.length; i++ ) {
document.getElementById( res[ i ] ).value = "";
}
return;
}
var i = 0;
res = _ajaxfilter.getResults();
for ( i = 0; i < res.length; i++ ) {
document.getElementById( res[ i ] ).value = _ajaxresultjsontext[ i ];
}
}
</script>
</head>
<body>
<div>codigo:<input type="text" id="id_contato" name="id_contato" onblur="javascript:teste();"><br>
nome:<input type="text" id="nm_contato" name="nm_contato"><br>
telefone:<input type="text" id="telefone" name="telefone"><br>
</div>
<br>
</body>
</html>
|