Ronny Riedel: Option wählen

Beitrag lesen

Hi,

soetwas in der Art?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"  
 "http://www.w3.org/TR/REC-html40/strict.dtd">  
<html>  
   <head>  
      <title>Options</title>  
      <script type="text/javascript">

~~~javascript function doMove(pE, pM) {
            var eleSlct = document.getElementById(pE);

if (eleSlct.selectedIndex < 0)
               return;

switch (pM) {
               case 0:
                  if (eleSlct.selectedIndex < (eleSlct.length - 1)) {
                     eleSlct.selectedIndex = eleSlct.selectedIndex + 1;
                  }
                  break;
               case 1:
                  if (eleSlct.selectedIndex > 0) {
                     eleSlct.selectedIndex = eleSlct.selectedIndex - 1;
                  }
                  break;
            }
         }

      ~~~html
</script>  
   </head>  
   <body>  
      <h3>Options</h3>  
      <form action="javascript:void(0);">  
         <select size="10" id="idSlct">  
            <option value="a">Anton</option>  
            <option value="b">Berta</option>  
            <option value="c">Caesar</option>  
            <option value="d">Dora</option>  
            <option value="e">Emil</option>  
            <option value="f">Friedrich</option>  
         </select>  
         <input type="button" value="&darr;" onclick="doMove('idSlct', 0);">  
         <input type="button" value="&uarr;" onclick="doMove('idSlct', 1);">  
      </form>  
   </body>  
</html>  

Grüße
  RR