| | |
Enter Zip and auto populate City and State
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2008
Posts: 2
Reputation:
Solved Threads: 0
I have a form set up in asp using Dreamweaver with a text box for Zip, City, and State. I want a person to fill in zip and then when they move to the next field to have it fill in city and state. I also have a database called zipcodes and a table called zip with zip, city, state fields. Can anyone tell me how to do this. I have tried so many different things and just can't get it to work.
•
•
•
•
I have a form set up in asp using Dreamweaver with a text box for Zip, City, and State. I want a person to fill in zip and then when they move to the next field to have it fill in city and state. I also have a database called zipcodes and a table called zip with zip, city, state fields. Can anyone tell me how to do this. I have tried so many different things and just can't get it to work.
Hi ! I am new to it too.... so i am not sure , if i'll really be able to help you out.. but here's what i can make of it...
you can store the zip in a variable by
strzip =<%form.request("zip") %> where zip is the name of the text box which gets the zip value
next you create a connection object
and then you create the record set
<%dim recordset1
set recordset1 = Server.CreateObject("ADODB.RecordSet")
recordset1.open "zipcodes" , <connection string>
' now we use the filter collection to filter the recordset according to your pin
recordset1.filter = " zip = strzip " %>
'here zip is the field in the table
<input type = "text" value =<%response.write("recordset1.fields("city")" name="text1")
<input type = "text" value =<%response.write("recordset1.fields("state")" name="text2")
<%recordset1.close
set recordset1 = nothing %>
I hope it helps... let me know ..
•
•
•
•
Hi ! I am new to it too.... so i am not sure , if i'll really be able to help you out.. but here's what i can make of it...
you can store the zip in a variable by
strzip =<%form.request("zip") %> where zip is the name of the text box which gets the zip value
next you create a connection object
and then you create the record set
<%dim recordset1
set recordset1 = Server.CreateObject("ADODB.RecordSet")
recordset1.open "zipcodes" , <connection string>
' now we use the filter collection to filter the recordset according to your pin
recordset1.filter = " zip = strzip " %>
'here zip is the field in the table
<input type = "text" value =<%response.write("recordset1.fields("city")" name="text1")
<input type = "text" value =<%response.write("recordset1.fields("state")" name="text2")
<%recordset1.close
set recordset1 = nothing %>
I hope it helps... let me know ..
i dont' think this would work..since we need a way to post the values back to the form...
somebody else plz help..
You need to use some Ajax. If you search the Ajax forum you will probably find the answer. You can also look at:
http://www.w3schools.com/ajax/default.asp
http://www.w3schools.com/ajax/default.asp
•
•
•
•
You need to use some Ajax. If you search the Ajax forum you will probably find the answer. You can also look at:
http://www.w3schools.com/ajax/default.asp
there are 2 ways to do it.
1. Ajax- through which you can make server request without refreshing the page.
2. on page load, store all the values in a string variable as
then when user enters zip code, the using client side script, you can filter out the values for this zip code and fill the state and country fields.
1. Ajax- through which you can make server request without refreshing the page.
2. on page load, store all the values in a string variable as
ASP Syntax (Toggle Plain Text)
str = "zip,state,country|zip,state,country|zip,state,country"
then when user enters zip code, the using client side script, you can filter out the values for this zip code and fill the state and country fields.
Vivek Rawat
Keep solving complexities.
Keep solving complexities.
![]() |
Other Threads in the ASP Forum
- Previous Thread: Inserting recurring dates into a MSSQL database.
- Next Thread: Installing reCaptcha for ASO w/ CDOSYS
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection dreamweaver excel fso iis msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption single specfic sqlserver sqlserverconnection windows7





