Enter Zip and auto populate City and State

Reply

Join Date: May 2008
Posts: 2
Reputation: ammwebmaster2 is an unknown quantity at this point 
Solved Threads: 0
ammwebmaster2 ammwebmaster2 is offline Offline
Newbie Poster

Enter Zip and auto populate City and State

 
0
  #1
Feb 27th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

Re: Enter Zip and auto populate City and State

 
0
  #2
Feb 27th, 2009
Originally Posted by ammwebmaster2 View 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.

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 ..
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

Re: Enter Zip and auto populate City and State

 
0
  #3
Mar 4th, 2009
Originally Posted by aashishn86 View Post
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..
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 213
Reputation: chrishea is an unknown quantity at this point 
Solved Threads: 32
chrishea's Avatar
chrishea chrishea is offline Offline
Posting Whiz in Training

Re: Enter Zip and auto populate City and State

 
0
  #4
Mar 4th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

Re: Enter Zip and auto populate City and State

 
0
  #5
Mar 4th, 2009
Originally Posted by chrishea View Post
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... !!
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 133
Reputation: vicky_rawat is an unknown quantity at this point 
Solved Threads: 17
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: Enter Zip and auto populate City and State

 
0
  #6
Apr 18th, 2009
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
  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.
Vivek Rawat
Keep solving complexities.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC