Results 1 to 4 of 4

Thread: Drop Down Menus

  1. #1
    only the finest beef
    Join Date
    Nov 2003
    Posts
    1,175
    Thanks
    4
    Thanked
    0 times in 0 posts

    Drop Down Menus

    Anyone got any idea on how to update a second drop down menu depending on the selection made in the first?

    For an example see http://www.topgear.com/content/used_cars/

    I'd prefer it if the code was VB script. I have to program in ASP (not .NET)

    The only solution I've come up with so far involves refreshing the whole page (which doesn't appeal to me.

  2. #2
    Put him in the curry! Rythmic's Avatar
    Join Date
    Jul 2003
    Location
    Twyford, Berks
    Posts
    758
    Thanks
    1
    Thanked
    0 times in 0 posts
    Unless you want to resort to frames, then you'll have to really on clientside scripts. Normally using asp to dump out db info into javascript arrays.

    You could use VBScript clientside, but only IE supports it.
    Now go away before I taunt you a second time.

  3. #3
    Member
    Join Date
    Aug 2003
    Location
    Wimbledon
    Posts
    141
    Thanks
    0
    Thanked
    0 times in 0 posts
    As rythmic said, normally use javascript on the client side.

    Heres some code to play with...

    Code:
    <html>
    <head>
    <script>
    
    model_arr = new Array();
    model_arr[0] = new Array('Focus', 'Escort', 'Mondeo', 'Transit');
    model_arr[1] = new Array('Clio', 'Scenic', 'Megane', '5 Turbo');
    model_arr[2] = new Array('Chevette', 'Vectra', 'Astra', 'Belmont');
    
    
    function manuf_changed()
    {
    	// Remove all previous options from models drop down
    	while(models.options.length > 0)
    		models.options.remove(0);
    
    	// Add a new option element for each element in the model sub-array
    	for(var i=0; i<model_arr[manufs.value].length; i++)
    	{
    		var oOption = document.createElement("OPTION");
    		models.options.add(oOption);
    		oOption.innerText = model_arr[manufs.value][i];
    		oOption.value = "";
    	}
    
    
    }
    </script>
    </head>
    <body>
    
    <select name="manufs" onchange="manuf_changed()" >
    	<option value="0">Ford</option>
    	<option value="1">Renault</option>
    	<option value="2">Vauxhall</option>
    </select>
    
    <br>
    <br>
    
    <select name = "models">
    	<option value="0">Pick a model</option>
    </select>
    
    </body>
    
    </html>

  4. #4
    only the finest beef
    Join Date
    Nov 2003
    Posts
    1,175
    Thanks
    4
    Thanked
    0 times in 0 posts
    Bloomin' Marvellous

    Cheers Mart!!


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •