Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Jul 2004
    Posts
    5
    Member #
    6588
    Hi,

    I'm working on a website for a map shop. To help the customer find the country they're interested in, I'd like to use two drop down menus - in the first, you choose the continent - this then populates the the second with all the countries in that continent. How would I go about doing this? Some kind of scripting I assume?

    Cheers muchly

    HT

  2.  

  3. #2
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    there are a couple of ways this can be done. I know of a pre-done function in PHP that does this, and ASP can do it as well. With just HTML (and maybe some javascript), it's a bit tougher. Basically when something is selected in the first dropdown, one way or another a value has to be passed to something to specify which continent was selected. This can be done with a form submit. You can have the 2nd dropdown have 7 sections of options (1 for each continent) with CSS around each group. The submitted value will be used to determine which CSS object to use. Only the one selected will be visible to the end user.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  4. #3
    Junior Member
    Join Date
    Jul 2004
    Posts
    5
    Member #
    6588
    Hmm ok...I've found some code that will populate the a box based on the choice of another:

    Code:
    <HTML>
    <HEAD><TITLE>Dynamic Select Lists</Title></Head>
    <BODY OnLoad="BuildContacts(0);">
    <FORM Name="myForm">
    Continent:
    <SELECT Name="SalesNames" OnChange="BuildContacts(this.selectedIndex);">
          <OPTION Value="Jeff">Africa
          <OPTION Value="Charles">Asia
          <OPTION Value="Rick">N + Cent. America
          <OPTION Value="Kevin">S. America
    	  <OPTION Value="Europe">Europe</OPTION>
    </Select>
    <BR><BR>
    Country:
    <!-- We want to define at least one option so that the select tag is created
           with the correct dimensions-->
    <SELECT Name="SalesContacts">
          <OPTION Value="">--------
    </Select>
    </Form>
    </Body>
    </Html>
    
    <SCRIPT Language="JavaScript"><!--
    
    //Build arrays for each person's contacts
    Contacts=new Array(5);
    Contacts[0]=new Array(3);
    Contacts[1]=new Array(2);
    Contacts[2]=new Array(5);
    Contacts[3]=new Array(4);
    Contacts[4]=new Array(6);
    
    //Charles
    Contacts[0][0]="Bill";
    Contacts[0][1]="Bob";
    Contacts[0][2]="Chuck";
    
    //Jeff
    Contacts[1][0]="Vern";
    Contacts[1][1]="Matt";
    
    //Rick
    Contacts[2][0]="Diana";
    Contacts[2][1]="Dave";
    Contacts[2][2]="Todd";
    Contacts[2][3]="Sherry";
    Contacts[2][4]="Sharon";
    
    //Kevin
    Contacts[3][0]="Brian";
    Contacts[3][1]="Trisha";
    Contacts[3][2]="Greg";
    Contacts[3][3]="Troy";
    
    //Europe
    Contacts[4][0]="Albania";
    Contacts[4][1]="France";
    
    //Call this to build the Contact list for the specified Salesperson
    function BuildContacts(num)
    {
          //Select the first Contact
          document.myForm.SalesContacts.selectedIndex=0;
          
          //For every contact in the array for this person, add a new option
          for(ctr=0;ctr<Contacts[num].length;ctr++)
          {
           document.myForm.SalesContacts.options[ctr]=new Option(Contacts[num][ctr],Contacts[num][ctr]);
          }
          //Set the length of the select list
          document.myForm.SalesContacts.length=Contacts[num].length;
    }
    //--></Script>
    What changes would I make to this so that I could press a 'Go' button which would then send me to a given page?

    Cheers

  5. #4
    Senior Member
    Join Date
    Apr 2003
    Location
    Las Vegas
    Posts
    231
    Member #
    1169


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:35 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com