CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002
    Location
    UK
    Posts
    20

    Clear a select control List

    I have 3 radio buttons and 1 select control.

    The select control is populated depending on which radio button is checked.

    When a radio button is clicked, I call a function that will clear the select control and polutate it again with a new list of elements.

    However, I am not able to clear all the elements properly.

    Is there any way I can clear all the elements in a select control at one go???

    Thanks

  2. #2
    Join Date
    Jan 2003
    Location
    North Carolina
    Posts
    309
    The fastest way to clear the list is to set the innerHTML of the Select to ''. This will wipe out all options within.

    Ex.

    Code:
    <select name=bob>
    <option value=1>t1
    <option value=2>t2
    <option value=3>t3
    <option value=4>t4
    </select>
    
    <input type=button name=X value=Clear OnClick="javascript:bob.innerHTML = ''">

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured