removing options

Results 1 to 2 of 2

Thread: removing options

  1. #1
    Join Date
    Dec 1969

    Default removing options

    Is there a way to remove options via javascript? I know that I can add options using field.options[x] = new Option("","")?<BR><BR>I need to be able to remove all options(considering this field is a dynamic field).<BR><BR>Matt

  2. #2
    Join Date
    Dec 1969

    Default The cross browser way... to set them all to null, starting with the last one and working to the front.<BR><BR>var sel = document.FormName.SelectName;<BR>for ( var ix = sel.options.length-1; ix &#062;= 0; --ix )<BR>&nbsp; &nbsp; sel.options[ix] = null;<BR><BR>Works for me in MSIE and NS 4.x. Untried in NS 6, but it should work.<BR><BR>

Posting Permissions

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