Multiple drop-down selectors -- please HELP !

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BigSister

    #1

    Multiple drop-down selectors -- please HELP !

    Hello,

    I have no java experience and need to know how to make four drop-down
    lists,
    with the selections in each list dependent on a selection made in the
    prior
    list. As an alternate, something similar to the category selector
    found on
    the eBay sell items webpage. Could anyone please send me the code on
    how to do this or point me to some freeware / shareware applet ?

    Thanks in advance!
  • The wee free man

    #2
    Re: Multiple drop-down selectors -- please HELP !

    This does it more or less. You'll have to write the rest yourself, but the
    code is identical for the other lists, except for the values of course ;-)

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Listbo x generator</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaS cript">

    function generateListBox 2(intSelectedVa lue)
    {
    var strHTML;

    strHTML = "<select onChange='gener ateListbox3(thi s.selectedIndex +1)'
    size='4'>";

    switch(intSelec tedValue) {

    case 1:
    strHTML = strHTML + "<option>PA RIS</option>";
    strHTML = strHTML + "<option>TOULOU SE</option>";
    strHTML = strHTML + "<option>CANNES </option>";
    strHTML = strHTML + "<option>NI CE</option>";
    break;
    case 2:
    strHTML = strHTML + "<option>BRUSSE LS</option>";
    strHTML = strHTML + "<option>ANTWER P</option>";
    strHTML = strHTML + "<option>GH ENT</option>";
    strHTML = strHTML + "<option>BRUGES </option>";
    break;
    case 3:
    strHTML = strHTML + "<option>RO ME</option>";
    strHTML = strHTML + "<option>PI SA</option>";
    strHTML = strHTML + "<option>FLOREN CE</option>";
    strHTML = strHTML + "<option>MANTUA </option>";
    break;
    case 4:
    strHTML = strHTML + "<option>BARCEL ONA</option>";
    strHTML = strHTML + "<option>MADRID </option>";
    strHTML = strHTML + "<option>GRANAD A</option>";
    strHTML = strHTML + "<option>SEVILL E</option>";
    break;
    }

    strHTML = strHTML + "</select>";

    document.getEle mentById("list2 ").innerHTM L = strHTML;
    }

    function generateListBox 3(intSelectedVa lue)
    {
    //same stuff
    }

    </script>
    </head>

    <body>
    <div id="list1">
    <select onChange="gener ateListBox2(thi s.selectedIndex +1)" size="4">
    <option>FRANC E</option>
    <option>BELGIUM </option>
    <option>ITALY </option>
    <option>SPAIN </option>
    </select>
    </div>

    <div id="list2"></div>

    <div id="list3"></div>

    <div id="list4"></div>

    </body>
    </html>


    Comment

    • Miguel Duran

      #3
      Re: Multiple drop-down selectors -- please HELP !

      Hi,

      Thanks! works well with two menus, but I tried a third one (so
      generateListBox 3), and it does not get thru. What is wrong here ???

      thanks.

      <html>
      <head>
      <title>Listbo x generator</title>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <script language="JavaS cript">
      function generateListBox 2(intSelectedVa lue)
      {
      var strHTML;

      strHTML = "<select onChange='gener ateListbox3(thi s.selectedIndex +1)'
      size='4'>";

      switch(intSelec tedValue) {

      case 1:
      strHTML = strHTML + "<option>pa ris</option>";
      strHTML = strHTML + "<option>toulou se</option>";
      strHTML = strHTML + "<option>cannes </option>";
      strHTML = strHTML + "<option>ni ce</option>";
      break;
      case 2:
      strHTML = strHTML + "<option>brusse ls</option>";
      strHTML = strHTML + "<option>antwer p</option>";
      strHTML = strHTML + "<option>gh ent</option>";
      strHTML = strHTML + "<option>bruges </option>";
      break;
      case 3:
      strHTML = strHTML + "<option>ro me</option>";
      strHTML = strHTML + "<option>pi sa</option>";
      strHTML = strHTML + "<option>floren ce</option>";
      strHTML = strHTML + "<option>mantua </option>";
      break;
      case 4:
      strHTML = strHTML + "<option>barcel ona</option>";
      strHTML = strHTML + "<option>madrid </option>";
      strHTML = strHTML + "<option>granad a</option>";
      strHTML = strHTML + "<option>sevill e</option>";
      break;
      }

      strHTML = strHTML + "</select>";

      document.getEle mentById("list2 ").innerHTM L = strHTML;
      }

      function generateListBox 3(intSelectedVa lue)
      {

      var strHTML;
      strHTML = "<select onChange='gener ateListbox4(thi s.selectedIndex +1)'
      size='4'>";

      switch(intSelec tedValue) {

      case 1:
      strHTML = strHTML + "<option>A</option>";
      strHTML = strHTML + "<option>B</option>";
      strHTML = strHTML + "<option>C</option>";
      strHTML = strHTML + "<option>D</option>";
      break;
      case 2:
      strHTML = strHTML + "<option>1</option>";
      strHTML = strHTML + "<option>2</option>";
      strHTML = strHTML + "<option>3</option>";
      strHTML = strHTML + "<option>4</option>";
      break;
      case 3:
      strHTML = strHTML + "<option>H</option>";
      strHTML = strHTML + "<option>I</option>";
      strHTML = strHTML + "<option>J</option>";
      strHTML = strHTML + "<option>K</option>";
      break;
      case 4:
      strHTML = strHTML + "<option>5</option>";
      strHTML = strHTML + "<option>6</option>";
      strHTML = strHTML + "<option>7</option>";
      strHTML = strHTML + "<option>8</option>";
      break;
      }

      strHTML = strHTML + "</select>";

      document.getEle mentById("list3 ").innerHTM L = strHTML;
      }

      </script>
      </head>

      <body>
      <div id="list1">
      <select onChange="gener ateListBox2(thi s.selectedIndex +1)" size="4">
      <option>franc e</option>
      <option>belgium </option>
      <option>italy </option>
      <option>spain </option>
      </select>
      </div>

      <div id="list2"></div>

      <div id="list3"></div>

      <div id="list4"></div>

      </body>
      </html>


      *** Sent via Devdex http://www.devdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Mick White

        #4
        Re: Multiple drop-down selectors -- please HELP !

        BigSister wrote:[color=blue]
        > Hello,
        >
        > I have no java experience and need to know how to make four drop-down
        > lists,
        > with the selections in each list dependent on a selection made in the
        > prior
        > list. As an alternate, something similar to the category selector
        > found on
        > the eBay sell items webpage. Could anyone please send me the code on
        > how to do this or point me to some freeware / shareware applet ?
        >
        > Thanks in advance![/color]



        This may help.
        Mick

        Comment

        • Miguel Duran

          #5
          Re: Multiple drop-down selectors -- please HELP !

          Great ! Thanks Mick. This is exactly what I needed. But I am having
          problems if I want to use a variable name with a number in it. If I
          write, for example:

          apple=["macintosh3",.. .];
          macintosh3=[...];


          ..I get an error. how can this be sorted out ? I really need to use
          names with numbers in the menus.

          Another question: how can I do so that the empty menus are hidden until
          they get filled in with some choice ?

          Thanks a lot,

          Miguel

          *** Sent via Devdex http://www.devdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          • Mick White

            #6
            Re: Multiple drop-down selectors -- please HELP !

            Miguel Duran wrote:
            [color=blue]
            >
            > apple=["macintosh3",.. .];
            > macintosh3=[...];
            >
            >
            > .I get an error. how can this be sorted out ? I really need to use
            > names with numbers in the menus.[/color]

            This shouldn't produce an error, numbers may be used in variable names.
            Do you have an example of this failure?
            [color=blue]
            > Another question: how can I do so that the empty menus are hidden until
            > they get filled in with some choice ?[/color]

            Are you planning to support NN4 browsers? If not, you can set display to
            "none":
            <select style="display: none" ...>
            Then in "createMenu " function:

            ....
            itemArray=eval( mainMenu[mainMenu.select edIndex].text);
            subMenu.length= 0;
            subMenu.style.d isplay='' ;// or 'inline'

            If you want to support NN4, let me know.
            Mick

            Comment

            Working...