Discussion Locked

Javascript Question

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I need to know where to get a code for my webpage.
This is what exactly I am trying to get done.
I want to have people coming to my sight use a form to put in their city and have some javascript
then send them to the webpage that matches their city.

Example They select Issaquah, WA
The code sees Issaquah as King County and
sends them to a webpage sepcifically for
King County.

I know this can't be too difficult code wise
the hard part will be doing what city goes
to where for thearea.

Can anyone lead me to a place where I can
pick up this kind of code?????

Thanks

3 replies

by mrcursor

OK maybe I wasn't as clear as I could be. I don't need a zipcode database.

I need a piece or example of javascript that checks a database and when it returns a hot to that database takes a person to a specific page in a website.

Like if they are from Boston, MA and Boston Ma in the choices
it will shove them to the Boston page in the website.

by port8080

You cannot access a database from client side Javascript code.
What you can do is and this is only possible if you are generating the form in a dynamic page is to create a Javascript hash map of all the cities as keys and related url's as values. On the submit event of the form access the city and get the related url and using the browsers location object redirect to the desired page
i.e document.location.href= value_obtained_from_hash;

This discussion is closed to new replies.