where can i find a form script that updates the "city list" when state is chosen?

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Not sure if you can do it in pure JavaScript. Sounds more like a dynamic server language would be required (ColdFusion, PHP, ASP, etc.) and I say that because I assume you'd get city names from a database. From what I understand, pure JavaScript cannot access a database (if it can be done, someone please share that with me??)

Thanks, Wolfshade. This is a related question and I think I'd rather go this route rather than having the select box repopulate with the cities.

Here is what I'm envisioning:

The user selects a state, then in the 'Cities' box, he starts typing the name of his city. However, it autocompletes the name for him based on the state he chose. So if he chose California and started typing in "Los Angeles", it would autocomplete "Los Angeles" for him. Does that make sense? Is there a script out there that can do this? It would be amazing.

I've seen events like what you describe, but I've never viewed the script that does that. Even then, you'd still have to use a database - if you manually created a JavaScript array that would contain that data, it would A) be freakin' HUGE, and B) take forever to type it all in, assuming someone hasn't already made one. Heck, who knows.. someone may have already made something like that using an Access database. IDK.

Possibility ...
1. Create 50 external JS or text files containing the cities of each state.
2a. Load individual selected JS files depending on state selected
or
2b. Use ajax to load text files of the cities of each state selected from the DD.

Using auto complete might be possible, but it might get too complicated for you
if you are a beginner.

Join Date: May 2007
Posts: 3
#2: May 19 '07
re: null or not an object error in IE works perfectly in Firefox

found a solution. basically Internet Explorer is crappy and doesnt like the setAttribute property so had to change the onchange handler by directly changing the attrbute for the object like so.
object.onchange = function() {}

Incase anyone has a problem like this i hope the solution helps

Moj

I found another thing saying how the dom object is created in IE , i am trying to find that link...