Code: Select all
//send a data request
function sendRequest(data,output,submit)
{
async.open("GET", "ajax/ajax.php?" + data + "&object=" + output + "&submit=" + submit, true);
async.onreadystatechange = getData;
async.send(null);
}
//get the data sent back
function getData()
{
if(async.readyState == 4 && async.status == 200)
{
var receivedText = async.responseText; //data as a string
if(receivedText .indexOf('|' != -1))
{
element = receivedText.split('|');
document.getElementById(element[0]).src = element[1]; //set the image source as good or bad
document.getElementById(element[2]).disabled = element[3]; //enable/disable the submit button
}
}
}Code: Select all
$valid = 0;
$extra = "";
if(strlen($_GET["ignore"]) > 0)
{
$extra = " and id != '".$_GET["ignore"]."'";
}
$find = mysql_query("SELECT * from ".$_GET["table"]." where ".$_GET["field"]."='".$_GET["value"]."'".$extra);
if(mysql_num_rows($find) > 0)
$valid = 0;
else
{
//CHECK IT IS VALID
if(strpos($_GET["value"], " ") === false)
$valid = 1;
}
if($valid == "1")
{
echo $_GET["object"]."|icon/good.gif|".$_GET["submit"]."|false"; //unique - good
}
else
{
echo $_GET["object"]."|icon/alert_high.gif|".$_GET["submit"]."|true"; //invalid characters
}
Code: Select all
<tr><td>Calling Name: </td>
<script type="text/javascript" src="ajax/basic.js"></script>
<input type="text" name="calling" id="calling" value="<? echo $out_calling; ?>" onKeyUp="sendRequest('existing&table=pageindex&ignore=<? echo $theid; ?>&field=calling&value=' + this.value, 'callingoutput', 'submit');"> <img src="icon/hidden.gif" id="callingoutput"></td></tr>
<tr><td> </td></tr>
<tr><td colspan=2 style="text-align: right;"><input type="submit" name="submit" id="submit" value="Submit"></td></tr>Help!