I'm writing some code for a postcode calculation, what I want to happen is instead of hitting submit to calculate the distances I want JQuery / Ajax to do this automatically when the text box changes...
Below is the code I have currently got, is there an easy way to inject so Ajax into this?
// Connect to the database server
$dbcnx = mysql_connect("", "", "");
if (!$dbcnx) {
echo( "
Unable to connect to the " .
"database server at this time (this is a host connect problem).
" ); exit();
}
// Select the database
if (! mysql_select_db("", $dbcnx) ) {
echo( "
Unable to locate the " .
"database at this time(this is a dbconnect problem).
" ); exit();
}
function calc_postcode_seperation($pcodeA,$pcodeB)
{
// PCODE A
$result=mysql_query("SELECT * FROM postcodes WHERE Pcode='{$_POST['pcodeA']}' LIMIT 1");
$row=mysql_fetch_array($result);
$gridn[0]=$row[Grid_N];
$gride[0]=$row[Grid_E];
// PCODE B $result=mysql_query("SELECT * FROM postcodes WHERE Pcode='{$_POST['pcodeB']}' LIMIT 1");
I'm writing some code for a postcode calculation, what I want to happen is instead of hitting submit to calculate the distances I want JQuery / Ajax to do this automatically when the text box changes...
Below is the code I have currently got, is there an easy way to inject so Ajax into this?
Thanks,
Scott
http://api.jquery.com/jQuery.ajax/
Has some great resources...
and as a starting point, instead of using .change() consider .blur()
e.g.: