p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Basics (http://p2p.wrox.com/forumdisplay.php?f=61)
-   -   Dynamic Menu - Using multiple dropdown boxes (http://p2p.wrox.com/showthread.php?t=224)

Sebastiaan June 6th, 2003 07:27 AM

Dynamic Menu - Using multiple dropdown boxes

I was wondering whether someone could help me with the following :

At works I saw an application using JavaScript to create dynamic menus. Based on the selection in the first <SELECT> box, the second <SELECT> box was created with associated values. Everytime that it got new information, there was a request back to the server without [that is what it seemed to do] refreshing the page. So, the page was left with the old contents and <SELECT> boxes were added with fresh data. I checked the JavaScript code and it seemed pretty advanced. However the technique used is quiute simple. The old page stays the same, but the <SELECT> boxes get updated by requesting new info. If you make a choice in the first box, you can clearly see the progress bar in the IE window at the bottom.

So what I would like to do is :

[All data is held in an MS ACCESS or SQL 2000 Database]

- create a form on a page with in the first select box the country name [eg. Belgium, UK, France, ... located in the coutnry table of the DB]
- the second box is not displayed as long as nothing is selected in the first box. It will hold the cities of that particular country [eg. Brussels, London, Paris, ... located in the cities table of the DB]


The database access would go through ASP.

I already tried making something similar by putting all data in an array, putting the array in different SELECT boxes and to hide/show them using Cascading Style Sheets. However, there is still no limit in tranfsfer to the server, and it will take all data from the database and load it in memory.

Can someone please help me out ? Does this all make sense ?

If so, you can still come over to Belgium, I'll buy you a fresh, nice beer !


Imar June 6th, 2003 09:36 AM

Hi Sebastiaan,

There are a few ways to overcome this problem. I won't give you any specific code, just general ideas. Depending on the option you choose, I could post further information here.

1. Smart Navigation. This is something that comes with ASP.NET and works for IE browsers only. Basically it provides for some smart UI updating / scrolling so the website looks more like a desktop app. You could look into the code supplied with the .NET framework for ideas.

2. Client side caching. Depending on the dynamic nature of your data you could retrive ALL information, store them in local .js files and use that info to build your lists dynamically. This may be a good option for country / state lists, as the number of items is rather limited.

3. Frames. You can use an (inline) frame to hold the drop down lists and nothing else. This way, you can requery new data without refreshing the whole page. The disadvantage of this however, is that it's harder to retrieve the info from the iframe than it is from other controls in your form.

4. Active X. Yak

5. Hidden frames. There are ways to requery the data in a hidden frame, and use the results for your drop downs. This way you can refresh the data without updating the screen.

There may be other ways as well, but this is all I can come up with on a Friday afternoon.



P.S. If you like one of the options; I'll be in Belgium in June for the Werchter festival....... ;)

Sebastiaan June 6th, 2003 05:33 PM

Vriendelijk dank Imar voor de verschillende opties, ActiveX zat ik al een tijdje aan te denken, Frames liever niet [maak de pagina weer een stuk lastiger voor de browser], ASP.NET is iets te vroeg om die weg te bewandelen, het zal de tweede optie worden denk ik !

Een goei pint hebt ge beslist verdiend, maar helaas ga ik niet naar Werchter dit jaar. Misschien Pukkelpop ?

Imar June 7th, 2003 06:38 AM

You're welcome. Option 2 would have been my choice as well.

Good luck building it.



All times are GMT -4. The time now is 08:49 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.