|
Posted by trpost on 02/27/07 23:12
Ok, Here is the code for what I am doing, and the ajax library being
used is SACK from http://twilightuniverse.com/projects/sack/ I just
can't seem to pass more than about 6100 characters... Any ideas, or a
better way to go?
<?php
//If some search criteria was sent
if(isset($_GET['searchCriteria']))
{
//////////////////////////////// DB
Connection ///////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
include('./adodb/adodb.inc.php');
//Type of connection
$db = NewADOConnection('oci8');
//Sets the query results to come back as assoc arrays
$db->SetFetchMode(ADODB_FETCH_ASSOC);
//Make the connection
$db->PConnect('xxxxx', 'yyyyy', 'zzzzz');
//////////////////////////////////////////////////////////////////////////////////////////////////////
$rs = $db->Execute("SELECT DISTINCT ID, NAME FROM PEOPLE WHERE
UPPER(NAME_DISPLAY) LIKE '".$_GET['searchCriteria']."%'");
$results = null;
while ($arr = $rs->FetchRow()) {
echo "obj.options[obj.options.length] = new
Option('".rawurlencode($arr["NAME"])."','".rawurlencode($arr["ID"])."');
\n";
}
exit;
}
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<!-- AJAX for processing customer name search -->
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript">
var ajax = new sack();
function searchInput(input)
{
//Set a variable to hold the value from the form input field
var searchCriteria = input.value;
//Empty results select box
document.getElementById('result').options.length = 0;
//If there is search criteria, then process
if(searchCriteria.length>0)
{
//Pass to php to process
ajax.requestFile = 'tst2.php?searchCriteria='+searchCriteria;
//Specify function that will be executed to display results
ajax.onCompletion = createResults;
//Execute AJAX function
ajax.runAJAX();
}
}
function createResults()
{
var obj = document.getElementById('result');
//Executing the response from Ajax as Javascript code
//Sent from php as an escaped string so must escape
alert(unescape(ajax.response));
eval(unescape(ajax.response));
}
</script>
<!-- END AJAX for processing customer name search -->
<table>
<tr>
<td><b>Customer Name:</b></td>
<td>
<input class="cust" id="search" name="search" type="text"
onchange="searchInput(this)">
</td>
</tr>
<tr>
<td> </td>
<td><select multiple size="10" id="result" name="result">
</select>
</td>
</tr>
</table>
[Back to original message]
|