alkativo: JS oder Prototype - select field checken

Hi,

für eine Edit Funktion möchte ich den Wert in einem select fiel vorauswählen.

  
<select id="select">  
<option selected="selected" value="0">keine Auswahl</option>  
<option value="1">1</option>  
  
<option value="2">2</option>  
<option value="3">3</option>  
<option value="4">4</option>  
<option value="5">5</option>  
</select>  

Wie mache ich das mit JS?

  
document.getElementById("select")[0].checked = true;  

Bitte helft mir. Danke.

Cucu
Al

  1. document.getElementById("select")[0].checked = true;

    
    >   
    > Bitte helft mir. Danke.  
    
    ~~~javascript
      
    document.getElementById("select")[0].selected;  
    
    

    ... so aus dem Kopf ... müsste es klappen ...

    1. Sehr gut

      document.getElementById("selected1").selected = true;

      Element eine id geben und los gehts...danke

      1. Hallo,

        Sehr gut

        document.getElementById("selected1").selected = true;

        Element eine id geben und los gehts...danke

        nein. Für sowas gibt es http://de.selfhtml.org/javascript/objekte/options.htm#selected_index@title=selectedIndex.

        MfG. Christoph Ludwig

        --
        Wo die Sprache aufhört, fängt die Musik an...
        Selfcode:  sh:( fo:| ch:} rl:( br:> n4:? ie:{ mo:) va:} js:| de:> zu:) fl:( ss:) ls:&
        Go to this
        1. nein. Für sowas gibt es http://de.selfhtml.org/javascript/objekte/options.htm#selected_index@title=selectedIndex.

          Stimmt da war doch was ;)

          document.getElementById("selected1").selectedIndex = 0;

  2. Hi,

    für eine Edit Funktion möchte ich den Wert in einem select fiel vorauswählen.

    Wie mache ich das mit JS?

    In dem du dich informierst, statt zu fragen.
    http://de.selfhtml.org/javascript/objekte/options.htm

    MfG ChrisB

    --
    Light travels faster than sound - that's why most people appear bright until you hear them speak.