topical media & game development
professional-ajax-10-JPSpan-Demo-CustomerClient-JPSpan.htm / htm
<html>
<head>
<title>Customer Client</title>
<script type="text/javascript" src="CustomerServer-JPSpan.php?client"></script>
<script>
function init()
{
remoteCustomer = new customer(customerCallback);
}
var customerCallback = {
getaddressfromemail: function(address)
{
showAddress(address);
}
};
function fetchAddress(Email)
{
if (!Email)
{
alert("Please enter your email address before choosing an item.");
document.getElementById("txtEmail").focus();
return;
}
remoteCustomer.getaddressfromemail(Email);
}
function showAddress(Address)
{
document.getElementById("txtForenames").value = replaceIfNull(Address["forenames"], "");
document.getElementById("txtSurname").value = replaceIfNull(Address["surname"], "");
document.getElementById("txtAddress1").value = replaceIfNull(Address["address1"], "");
document.getElementById("txtAddress2").value = replaceIfNull(Address["address2"], "");
document.getElementById("txtAddress3").value = replaceIfNull(Address["address3"], "");
document.getElementById("txtAddressTown").value = replaceIfNull(Address["addressTown"], "");
document.getElementById("txtAddressStateCounty").value = replaceIfNull(Address["addressStateCounty"], "");
document.getElementById("txtAddressZipPC").value = replaceIfNull(Address["addressZipPC"], "");
document.getElementById("txtAddressCountry").value = replaceIfNull(Address["addressCountry"], "");
if (!Address["success"])
{
alert("Address not registered, please fill in details.");
document.getElementById("txtForenames").focus();
}
}
function replaceIfNull(Value, ReplaceWith)
{
if (Value == null)
{
return ReplaceWith;
}
return Value;
}
</script>
</head>
<body onload="init();">
<table width="60%" align="left">
<tbody>
<tr>
<td width="25%">Enter your email address:</td>
<td width="75%">
<input type="text" id="txtEmail" size="30"
value="hmqueen412@yahoo.com"
onblur="fetchAddress(document.getElementById('txtEmail').value);">
</td>
</tr>
<tr>
<tr>
<td>Choose an item:</td>
<td>
<select>
<option>Lear Jet</option>
<option>Rolls Royce Car</option>
<option>Luxury Yacht</option>
<option>Wrox Book</option>
</select>
</td>
</tr>
<td>Forenames:</td>
<td><input type="text" id="txtForenames" size="50"></td>
</tr>
<tr>
<td>Surname:</td>
<td><input type="text" id="txtSurname" size="50"></td>
</tr>
<tr>
<td>Address 1:</td>
<td><input type="text" id="txtAddress1" size="50"></td>
</tr>
<tr>
<td>Address 2:</td>
<td><input type="text" id="txtAddress2" size="50"></td>
</tr>
<tr>
<td>Address 3:</td>
<td><input type="text" id="txtAddress3" size="50"></td>
</tr>
<tr>
<td>Town/City:</td>
<td><input type="text" id="txtAddressTown" size="50"></td>
</tr>
<tr>
<td>State/County:</td>
<td><input type="text" id="txtAddressStateCounty" size="50"></td>
</tr>
<tr>
<td>ZIP/Post Code:</td>
<td><input type="text" id="txtAddressZipPC" size="50"></td>
</tr>
<tr>
<td>Country:</td>
<td><input type="text" id="txtAddressCountry" size="50"></td>
</tr>
</tbody>
</table>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.