Skip to main content
Inspiring
August 15, 2007
Question

AutoFill City & State by typing in ZipCode

  • August 15, 2007
  • 1 reply
  • 1182 views
Here is a great example of using AJAX to automatically lookup the City & State by just typing in the Zip Code.
Problem is I cannot get it to work? I type in the Zip code & nothing happens to the City & State fields?
Since the XML code works fine I'm sure the issue is with my Ajax code on my Main Form (listed below) and how I'm assigning the values to the variables & then to my Form fields..?

I have attached the code to my files below:
1) Part of the Dreamweaver form code that has the AJAX code & my Form fields.
- Here is a link to my site: http://www.clearwave.biz/Beta/T1COElogin.cfm (username is: Beta password is: 123) Click on the "Add New T1" button to see my Main form and View Source to my full Form code.
2) The getZipInfo.cfm code that creates the XML data.
- Here is a link to the getZipInfo.cfm file:
I tested it using http://www.clearwave.biz/Beta/getZipInfo.cfm?URL.zip=62948 & got back the correct XML values for that Zip so I know the XML is working fine.

I’m using : onblur="updateCityState();" on my T1BusZip field on my Form like this:
<tr>
<td class="KT_th"><label for="T1BusZip">Zipcode:</label></td>
<td colspan="2"><input name="T1BusZip" onBlur="updateCityState();" id="T1BusZip" value="<cfoutput>#Request.KT_escapeAttribute(rstblT1OrderProcessing2.T1BusZip)#</cfoutput>" size="32" wdg:subtype="MaskedInput" wdg:mask="99999" wdg:restricttomask="yes" wdg:type="widget" />
<cfoutput>#tNGs.displayFieldHint("T1BusZip")#</cfoutput> <cfoutput>#tNGs.displayFieldError("tblT1OrderProcessing2", "T1BusZip")#</cfoutput> </td>
</tr>


ps: Here is the link to the original source of this project: http://jamesedmunds.com/testing123/ajaxtest2.cfm

Thanks for any assistance,
jlig
This topic has been closed for replies.

1 reply

Participant
November 9, 2010

This post may help: http://nerdbombs.wordpress.com/2010/11/03/zipcode/

It uses Ajax and a php array to automatically display the city and state after a user enters their zip code in a form.