select all elements of one selection list

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

    select all elements of one selection list

    hello I'm french so I hope I hunderstand your answers ! I'm begginer
    in javascript and I would like to do this :

    select all elements of one selection list (html) with a javascript
    fonction

    could you help me ?

    thanks lot !
  • Lasse Reichstein Nielsen

    #2
    Re: select all elements of one selection list

    gsmurf@mageos.c om (GiSmo) writes:
    [color=blue]
    > hello I'm french so I hope I hunderstand your answers ! I'm begginer
    > in javascript and I would like to do this :
    >
    > select all elements of one selection list (html) with a javascript
    > fonction[/color]

    It requres the select element to accept multiple selected options
    (e.g., the tag contains the "multiple" attribute).

    Assume "selectRef" refers to the select element:

    for (var i=0;i<selectRef .options.length ;i++) {
    selectRef.optio ns[i].selected = true;
    }

    That is, set the "selected" field of each option to "true".

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • GiSmo

      #3
      Re: select all elements of one selection list

      Thx lot it work !

      at a next time

      Comment

      Working...