Dynamic Drop-Down List (Full Version)

All Forums >> [Web Development] >> General Web Development



Message


Jason23 -> Dynamic Drop-Down List (3/11/2004 21:19:32)

How do I make a dynamic dropdown list? I need 4 drop down boxes all dependent on on another and the last drop down box will redirect to a specific page for that particular selection. This type of script is new to me and don't even know where to begin.

Any help is greatly appreciated!

Thanks.




Richard Dudley -> RE: Dynamic Drop-Down List (3/11/2004 21:49:06)

This is not a simple task. There are a couple of ways to approach the task, though.

The first way is to have the form submit to itself when the option is changed. When the form submits to itself, the form handler checks for the selection, and reads the next values from a database. This is actually the easier of the two methods, but it will require 4 round trips to the server, which can get time consuming.

A second way is to store every option in javascript variables. When a selection is made, a javascript fires that reads the selected value, and loads the next values based on that selection. I have just completed a very complicated form using this methd. The advantage is that it is nearly instantaneous to your users. But it's a real challenge for you.

First thing to decide is do you want the hard way that's better for your users, or the easy way that's a pain for the users? There's a hybrid method I'm working on, but it's not done yet, so I can't provide any bit of assistance on it yet. Once you figure out which way you want to go, I can give you some more direction.




Jason23 -> RE: Dynamic Drop-Down List (3/11/2004 22:25:26)

This isn't looking good! lol....I can't afford to take the time it takes to code using the java method but it would be nice to make the form as easy as possible for the user. I looked at a sample javascript code for a 2 drop down list function and I could see the coding could get very detailed and take a long time to get the form to work the way I need it.

What is all involved in the database version? I'm thinking this might be my best option since I need to program this asap.

Thanks for your help!




AMysticWeb -> RE: Dynamic Drop-Down List (3/12/2004 4:05:16)

Hi Jason23,

There is a Triple Menu Script available. I have yet to find a quadruple script however.

I use it for my site navigation.

I am not good at coding and it took me a while to set it up. It is basically a duplication process to add options, but I am not good at following directions.

Although my menu works, I have still been too lazy to finish it up.

From the sounds of it, you might have greater overall success with Richard's method.




Richard Dudley -> RE: Dynamic Drop-Down List (3/12/2004 8:11:14)

I'm assuming that for this example, the values in box 2 rely only on the selected value in box 1, and the values in box 3 correspond only to the value in box 2, and the values in box 4 rely only on the selected value in box 3 (the example I just finished did not, and was a little more complicated). I'm also doing this off the cuff, so some parts may need a little clarification later.

For your database, you need to set up tables containing the values for box 2, 3 and 4 (hard code box 1 unless it will change often). The table should have three columns--parent value, value, and text.

Each select box will fire a small javascript in the onChange event. Something like onChange="fncFillNext(this.id)". The javascript function will basically submit this form to itself. This is one of those parts that will require some elaboration.

A form handler on the page reads the value of what box was selected (from this.id), and what the selected value is, and retrieves the values of the next box from the database. This information is used to populate the select box.

It's a little simpler, but requires four loads of the page.




LoriL1212 -> RE: Dynamic Drop-Down List (3/12/2004 16:55:58)

I can help you here...

Are you looking for a "dropdown menu" - like at http://www.seaspecialties.com/

Or are you looking for a "form field on select" script?




Jason23 -> RE: Dynamic Drop-Down List (3/12/2004 18:42:22)

Richard:

Yes, you are correct. Each box relies on what data was selected in the previous box. I am going to setup a database and try coding the drop down boxes from that dbase. I am sure more questions will come after I get started! Thanks.

LoriL1212:

I need a form that has 4 drop down text boxes that relies on one another. For example the first drop down box has 3 selections (A, B, C) if I select B then the second drop down box pulls 3 more selections that are directly related to my selection from the first box., and so on. Maybe the term for this type of script is the "form field on select" script. I am not sure.

AMysticWeb:

Is that script you are referring to a dbase driven script or javascript?

Thanks everyone!




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
6.298828E-02