mozilla
Your Search Results

    removeAllItems

    This page has no content. Enrich MDC by contributing.

    So,

    this code :

    var o = document.getElementById( "Category" );

     

    o.removeAllItems();

    o.appendItem( "1d", "1" , "2a");

    o.appendItem( "2d", "2" , "2b");

    o.appendItem( "3d", "3" , "2c");

    o.appendItem( "4d", "4" , "2d");

    will completely freeze the menulist "Category", I guess thats because the old selected value is no longer a valid menuitem.

    The only way to code around this that I found is to set the selectedIndex to a valid menuitem. Of course I did not want any value to be preselected, I wanted a visual clue that the user needs to make a decision. So I ended up with this:

     

    var o = document.getElementById( "Category" );

    o.removeAllItems();

    o.appendItem( "Select a category", "1" , "2a");

    o.appendItem( "1d", "1" , "2a");

    o.appendItem( "2d", "2" , "2b");

    o.appendItem( "3d", "3" , "2c");

    o.appendItem( "4d", "4" , "2d");

    o.selectedIndex = 0;

    o.removeItemAt( 0 );

    This works..

    TjD

    Document Tags and Contributors

    Contributors to this page: Konijn
    Last updated by: Konijn,