I'm totally lost! I've been trying for several days to make Onblur fill in the city, state after the user inputs inside a textbox a 5 digit zip code, from the the zip, city, state text boxes I want to extract the info and pu it in a separate line like this:
a) user puts a zipcode:95051
b) Onblur fills in city and state
c) a new line in the same page showing ex.
Support Services
SantaClara,CA 95051
I have a test page loaded with all the code here: http://www.echildcarem anagement.com/prototype/step6.html
The HTML code:
Thanks for your help!
Ed
PS pbmods has been helping, somehow it was working before now is not working? am I missing something inside the DIV tags?
a) user puts a zipcode:95051
b) Onblur fills in city and state
c) a new line in the same page showing ex.
Support Services
SantaClara,CA 95051
I have a test page loaded with all the code here: http://www.echildcarem anagement.com/prototype/step6.html
The HTML code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ZIP Code to City and State using XmlHttpRequest</title>
<script language="javascript" type="text/javascript">
var url = "CityState.php?param="; // The server-side script
function handleHttpResponse() {
if (http.readyState == 4) {
// Split the comma delimited response into an array
results = http.responseText.split(",");
document.getElementById('city').value = results[0];
document.getElementById('state').value = results[1];
document.getElementById('areacode').value = results[2];
document.getElementById('zip').firstChild.nodeValue = city + ', ' + state;
document.getElementById('zip1').firstChild.nodeValue = zip;
}
}
function updateCityState() {
var zipValue = document.getElementById("zip").value;
http.open("GET", url + escape(zipValue), true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
</script>
<style type="text/css">
<!--
.style1 {
font-size: 16px;
font-weight: bold;
font-style: italic;
}
-->
</style>
</head>
<body>
<p> </p>
<p> </p>
<p class="style1"><fieldset>
<legend>Computer information:</legend>
<legend><div id="city1"></div></legend>
<legend>
<div id="state1"></div>
</legend>
<legend>
</legend>
</fieldset></p>
<p class="style1">Schedule your services now!</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<form action="post">
<p>ZIP code:
<input type="text" size="5" name="zip" id="zip1" onblur="updateCityState();" />
</p>
City:
<input type="text" name="city" id="city1" />
State:
<input type="text" size="2" name="state" id="state1" />
</form>
</body>
</html>
Ed
PS pbmods has been helping, somehow it was working before now is not working? am I missing something inside the DIV tags?
Comment