943,867 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 2747
  • ASP RSS
Feb 27th, 2009
0

Enter Zip and auto populate City and State

Expand Post »
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ammwebmaster2 is offline Offline
6 posts
since May 2008
Feb 27th, 2009
0

Re: Enter Zip and auto populate City and State

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 ..
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008
Mar 4th, 2009
0

Re: Enter Zip and auto populate City and State

Click to Expand / Collapse  Quote originally posted by aashishn86 ...
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..
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008
Mar 4th, 2009
0

Re: Enter Zip and auto populate City and State

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
Reputation Points: 210
Solved Threads: 228
Nearly a Posting Virtuoso
chrishea is offline Offline
1,389 posts
since Sep 2008
Mar 4th, 2009
0

Re: Enter Zip and auto populate City and State

Click to Expand / Collapse  Quote originally posted by chrishea ...
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
well there has to be a way without it... !!
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008
Apr 18th, 2009
0

Re: Enter Zip and auto populate City and State

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
ASP Syntax (Toggle Plain Text)
  1. 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.
Reputation Points: 28
Solved Threads: 19
Junior Poster
vicky_rawat is offline Offline
137 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: Inserting recurring dates into a MSSQL database.
Next Thread in ASP Forum Timeline: Installing reCaptcha for ASO w/ CDOSYS





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC