Dynamic Drop-Downs (again)

They have: 330 posts

Joined: Apr 2000

I am confused. I have been trying to get multi-level dynamic drop-down boxes to work for over a month and can't do anything with it. Every site I find with sample code for it has a lot of javascript that I can't understand and it seems like it's too much work.

I would believe there should be a way to do this which would make everything a lot more simple and easily expandable.

Have a few functions lined up which are executed with an onChange command for each drop-down. When the first drop-down is changed the function should then change the SQL statement which populates the 2nd drop-down box. The same should be possible for the 3rd, 4th, etc.

Why wouldn't this work? If it does, why does everyone use 4 pages of javascript code instead?

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi artsapimp,

I'm sorry -- I guess I didn't read through your previous post when I gave you my last response.

1) you cannot use javascript to access a dbms; javascript can only deal with arrays & like data in the html file itself or a js file. Therefore, you cannot use it directly to change the sql statements to create a new table of data

2) you need to do this server side; you can use javascript for the selection list, but then you would have to pass the selected option's value to the server -- which (using php, asp, or something) would then get the new data and rewrite the page -- ad infinitum or until done.

3) the only way to do it completely in javascript is to download all the database into appropriate arrays before any selection is made and then use javascript to access the arrays.

So, my recommendation is to have one of the mods move this to the server side forum and to tell Peter, etal. what kind of services you have available. A url showing what you have so far would help also.

Vinny

Where the world once stood
the blades of grass cut me still

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.