SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    removing items from a dropDown List

    I can add items dynamically to my dropDownList using the syntax:

    oNewOption = new Option();
    oNewOption.text = "yahoo";
    oNewOption.value = "http://www.yahoo.com";
    document.myform.SitesList.add(oNewOption, 1);

    BUT, how can i remove items if i wanted to?

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi jay,

    fancy seeing you here.

    <form name="b">
    <select name='a'>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    </select>
    </form>
    <script language='javascript'>
    <!--
    document.b.a.options.length--;
    alert(document.b.a.options.length)
    document.b.a.options[2] = null;
    alert(document.b.a.options.length)

    //-->
    </script>

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

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