Stefan Pottinger: Wie den selektierten OPTION-value in eine TEXTAREA schreiben?

Beitrag lesen

Hallo JU!

Das hier hat bei mir getan:

<html></head>

<script type="text/javascript">
<!--
    function uebernehmeAuswahl() {
          var index = document.getElementById("select").selectedIndex;
          if(index != -1) {
               var selectText = document.getElementById("select").childNodes[index].text;
               document.getElementById("ta").value = document.getElementById("ta").value + selectText + "\n";
         }
       }
//-->
</script>
</head>
<body>
<table width="99%"><tr><td>
Betroffene Bereiche: <BR>
<SELECT id="select" NAME="bereiche" size="8">
<option value="Außen">Außen</option>
<option value="Innen">Innen</option>
<option value="Vorne">Vorne</option>
</select>
<a href="javascript:uebernehmeAuswahl();">Bereich hinzufügen</a>
</td>
<td>
<TEXTAREA id="ta" NAME="bereichegewaehlt" ROWS="9" COLS="25"></TEXTAREA><BR>
</td></tr></table>
</body>
</html>

Aber beachten:

http://selfhtml.teamone.de/javascript/objekte/node.htm#child_nodes_nn6x

Stefan