<html>
<head>
<title>Auswahllisten deselektieren, setzen und auslesen</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--

function show_text_note()
{
   // Variablen mit Leerstring initialisieren
   myText="";
   myValue="";

   // Gr��e der Einfachauswahlliste ermitteln
   anzahl=document.inputForm.note.length;

   for (i=0; i<anzahl;i++)
   {
      if (document.inputForm.note.options[i].selected)
      {
         // zugeh�rigen Text f�r die Ausgabe ermitteln
         myText=document.inputForm.note.options[i].text;
         myValue=document.inputForm.note.options[i].value;
      }    
   }
    
   // Text komplett fertig zusammenbauen
   myText= "Notenliste: " + myText + " hat den Wert " + myValue + "\n";

   return myText;
}

function show_text_hobbies()
{
   // Variable mit Leerstring initialisieren
   myText="";
   myValue="";
   myZeilen="";

   // Gr��e der Mehrfachauswahlliste ermitteln
   anzahl=document.inputForm.hobbies.length;

   for (i=0; i<anzahl;i++)
   {
      if (document.inputForm.hobbies.options[i].selected)
      {
         // Text zeilenweise zusammenbauen
         myText=document.inputForm.hobbies.options[i].text;
         myValue=document.inputForm.hobbies.options[i].value;
         myZeilen=myZeilen+"Hobbyliste: " + myText + " hat den Wert " + myValue + "\n";
      }    
   }

   return myZeilen;
}


function myShowData()
{
   // Variable definieren
   var text;
   text=show_text_note();
   text=text+show_text_hobbies();
   alert(text);
}

function myClearData()
{
   // alle Eingabefelder leeren
   anzahl=document.inputForm.note.length;

   for (i=0; i<anzahl;i++)
   {
      document.inputForm.note.options[i].selected=false;
   }

   anzahl=document.inputForm.hobbies.length;

   for (i=0; i<anzahl;i++)
   {
      document.inputForm.hobbies.options[i].selected=false;
   }
}

//-->
</script>

</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="inputForm"  onSubmit="myShowData()">
   <table border="0" cellspacing="5" cellpadding="0">
   <tr>
      <td>
         <label>Notenliste: </label>
      </td>
      <td>
         <select name ="note" size="1">
            <option value="a">Sehr gut</option>
            <option value="b">Gut</option>
            <option selected value="c" >Befriedigend</option>
            <option value="d">Gen�gend</option>
            <option value="e">Nicht gen�gend</option>
         </select>
      </td>
    </tr>
    <tr>
       <td align="left" valign="top"> 
          <label>Hobbies: </label>
       </td>
       <td>
          <select name ="hobbies" size="5" multiple>
             <option selected value="a">Rad fahren</option>
             <option value="b">Schwimmen</option>
             <option selected value="c">Segel fliegen</option>
             <option value="d">Fu&szlig;ball spielen</option>
             <option selected value="e">Tanzen</option>
         </select>
      </td>
    </tr>
    <tr>
      <td align="left">
         <input type="button" value="Deselect" onClick="myClearData()">
      <td align="right">
         <input type="submit" value="Show">
      </td>
    </tr>
   </table>
</form>
</body>
</html>