dynamic option list

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

    #1

    dynamic option list

    I have generated a dynamic option list from an array using
    elementCreate(" OPTION")

    I now wish to get an event to replace this list with a new one, but of
    course currently, it simply adds them on to the end of the list.

    Can I Delete or overwrite the options and if so by what method?

    Many thanks

    Phil


  • johkar

    #2
    Re: dynamic option list

    Try document.YourFo rmName.YourSele ctName.options. length=0;

    John

    "Philip WATTS" <PRWATTS@syring a.freeserve.co. uk> wrote in message
    news:cb1vg9$ufs $1@newsg4.svr.p ol.co.uk...[color=blue]
    > I have generated a dynamic option list from an array using
    > elementCreate(" OPTION")
    >
    > I now wish to get an event to replace this list with a new one, but of
    > course currently, it simply adds them on to the end of the list.
    >
    > Can I Delete or overwrite the options and if so by what method?
    >
    > Many thanks
    >
    > Phil
    >
    >[/color]


    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: dynamic option list

      Philip WATTS wrote:[color=blue]
      > I have generated a dynamic option list from an array using
      > elementCreate(" OPTION")[/color]

      This is not a built-in method of any widespread DOM.
      [color=blue]
      > I now wish to get an event to replace this list with a new one,[/color]

      You should get informed about what an event is. Probably you are
      looking for event listener code triggered by an intrinsic event
      handler.
      [color=blue]
      > but of course currently, it simply adds them on to the end of the list.
      >
      > Can I Delete or overwrite the options and if so by what method?[/color]

      Try this:

      <form action="...">
      <select name="mySelect" >
      <option value="foo">bar </option>
      ...
      </select>
      <input
      type="button"
      value="Replace"
      onclick="this.f orm.elements['mySelect'].options[0].text = 'foobar';">
      <input
      type="button"
      value="Clear"
      onclick="this.f orm.elements['mySelect'].options.length = 0;">
      ...
      </form>


      PointedEars

      Comment

      Working...