Hello,
I am a newbe at php.
I am building a form that needs to go back to the database and get a value when a user fills
in a slef.
Here is what I have so far
[code=php]
<?
$today=date(‘m/d/Y’);
?>
<html>
<head>
<title>Test</title>
<script language=”javascript” src=”pofunctions.js”></script>
<link rel=”stylesheet” type=”text/css” href=”standard.css”>
<script language=’javascript’>
<!–
function lookupStoreAddress(formname)
{
if (str==””)
{
document.getElementById(“test”).innerHTML=””;
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(“test”).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open(“GET”,”getStoreAddress.php?store=”+str,true);
xmlhttp.send();
}
–>
</script>
</head>
<body
<input class=’inputField’ type=’text’ name=’store’ onblur=”lookupStoreAddress(this)”>
<input class=’inputField’ type=’text’ name=’addressStreet’ readonly=”readonly” size=’40’ >
<input class=’inputField’ type=’text’ name=’city’ readonly=”readonly” size=’40’ >
<input class=’inputField’ type=’text’ name=’state’ readonly=”readonly” size=’40’ >
</body>
</html>
I have built a php file, getStoreAddress.php
Based on w3schools
[url]http://www.w3schools.com/php/php_ajax_database.asp
Which takes in:
[code=php]
<?php
$store=$_GET[“store”];
…
…
mysql_close($con);
?>
What is the easest/best way to return the values (address, city, state) from getStoreAddress.php
and get them on the main form.
also,
I am not sure what to do with the “test” in lookupStoreAddress
thanks