...

View Full Version : Sajax



mic2100
08-11-2006, 03:24 PM
i have been developing some code, the purpose of validating the booking in of a referral on a specific date, i have been trying to use SAJAX without much success (i can only get the examples working as soon as i do summet to em they don't work).



function return_string($refnum)
{

require_once('Connections/Con_SJMDatabase.php');

mysql_select_db($database_Con_SJMDatabase, $Con_SJMDatabase);
$query_rs_checkRef = "SELECT * FROM tbl_referrals WHERE ReferralNum = ".$refnum;
$rs_checkRef = mysql_query($query_rs_checkRef, $Con_SJMDatabase) or die(mysql_error());
$row_rs_checkRef = mysql_fetch_assoc($rs_checkRef);
$totalRows_rs_checkRef = mysql_num_rows($rs_checkRef);

if($totalRows_rs_checkRef == 0)
{

$msg = 'No referral found.';

}
else
{

$msg = 'Name: '.$row_rs_checkRef['surname'].'<br>Address: '.$row_rs_checkRef['AddressLine1'].' '.$row_rs_checkRef['AddressLine2'].'<br>County: '.$row_rs_checkRef['County'].'<br>Postcode: '.$row_rs_checkRef['Postcode'];

}

return $msg;
#return $value;

}


and this is the code for the javascript part of it



<script>
<?
sajax_show_javascript();
?>
function display_result(val) {
var repr;

repr = "";
repr += "Type: " + typeof val + "\n";
repr += "Value: ";
if (typeof val == "object" ||
typeof val == "array") {
repr += "{ ";
for (var i in val)
repr += i + ": " + val[i] + ", ";
repr = repr.substr(0, repr.length-2) + " }";
} else {
repr += val;
}
alert(repr);
}
</script>

<button onClick="x_return_string(213453, display_result);">Return as string</button>


i am new to this and i really don't quite understand it. could anyone help me by showing me where i am going wrong???

Beagle
08-14-2006, 03:40 PM
What's the problem? What's occuring? What's supposed to be happening? How do they differ?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum