dynamic drop-menu content?

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

    dynamic drop-menu content?

    I've a page where I have two form drop-menu. I need the second menu to
    populate only with items based on what's selected in the 1st menu.

    I have "Javescript in Easy Steps" and the closest it discusses is
    populating list content based on a radio button, but the book is so
    badly written, I'm having a horrible time trying to adjust using two
    menus.

    I did a Google for the sublect, and found
    http://www.blazonry.com/javascript/js_menu.php which is easier to
    understand, but I still can't get it to work.

    All I need is a link to a good Web page that discusses this topic, and
    I'll figure it out on my own. If anyone has any Web sites they know
    that deal with this?
    Thanks!

    Liam
  • Dominique

    #2
    Re: dynamic drop-menu content?

    two options...

    use Arrays for items
    or

    //-------------start copy
    <script language="Javas cript">
    function getItems(val) {
    if (val) { //check that there IS a selection
    made
    document.getEle mentById("conta iner").innerHTM L =
    document.getEle mentById("item" +val).innerHTML
    }
    }
    </script>

    <div id=item1 style="display: none">
    <select name=itemsfor1>
    <option>11111 </option>
    <option>1111111 1</option>
    </select>
    </div>
    <div id=item2 style="display: none">
    <select name=itemsfor2>
    <option>22222 </option>
    <option>2222222 2</option>
    </select>
    </div>
    <div id=item3 style="display: none">
    <select name=itemsfor3>
    <option>33333 </option>
    <option>3333333 3</option>
    </select>
    </div>

    <form name=whateva>
    <select name=select1 onchange="getIt ems(this.value) ">
    <option value="">Select </option>
    <option value=1>Item list 1</option>
    <option value=2>Item list 2</option>
    <option value=3>Item list 3</option>
    </select>


    <div id=container></div>

    </form>
    //--------------------end copy

    copy everything AS IS and place it in an html page and test it...

    this was rushed, so forgive mistakes...

    what you can do then is give each option in the item lists values and/or put
    onchange events for those select boxes so that they do something.






    "LRW" <deja@celticbea r.com> wrote in message
    news:3a1d1813.0 405060659.481b9 5c7@posting.goo gle.com...[color=blue]
    > I've a page where I have two form drop-menu. I need the second menu to
    > populate only with items based on what's selected in the 1st menu.
    >
    > I have "Javescript in Easy Steps" and the closest it discusses is
    > populating list content based on a radio button, but the book is so
    > badly written, I'm having a horrible time trying to adjust using two
    > menus.
    >
    > I did a Google for the sublect, and found
    > http://www.blazonry.com/javascript/js_menu.php which is easier to
    > understand, but I still can't get it to work.
    >
    > All I need is a link to a good Web page that discusses this topic, and
    > I'll figure it out on my own. If anyone has any Web sites they know
    > that deal with this?
    > Thanks!
    >
    > Liam[/color]


    Comment

    • Matt Kruse

      #3
      Re: dynamic drop-menu content?

      LRW wrote:[color=blue]
      > I've a page where I have two form drop-menu. I need the second menu to
      > populate only with items based on what's selected in the 1st menu.[/color]

      There are a lot of solutions out there, and a lot of them don't work as well
      as they could.
      Simple solutions that are often posted here work in the simplest
      environments and most current browsers, but fail on others.

      I have a dynamic option list library which is pretty robust and handles a
      lot of features you might need (like default values when the page loads,
      handling form reset, etc).
      It's at http://www.mattkruse.com/javascript/dynamicoptionlist/

      Hope that helps,

      --
      Matt Kruse
      Javascript Toolbox: http://www.mattkruse.com/javascript/


      Comment

      Working...