Select option im Internet Explorer

N

Netzwerkidi

Hallo,

weiß einer, wie man dem Internet Explorer sagen kann, dass er bitte den selektierten Werte anzeigen soll? Ich habe schon das Event-Objekt dynamisch durchgerödelt, aber ich finde nicht, wo der selektierte Werte abgelegt ist.

HTML:
<html>  
  <head>    
  <title></title>     
  <script src="http://code.jquery.com/jquery-latest.js"></script>  
  <script type="text/javascript">
 
  $(document).mousedown(function(event) {
    var e = event ? event.target : window.event;
    switch (e.tagName) {
      case 'SELECT': // IE
        alert( ' ****?: '+'e.****?');
        break;
      case 'OPTION': //Firefox u. a.
        alert( ' TEXT: '+e.text);
        break;
      case 'IMG':
        alert( ' SRC: '+e.src);
        break;
      case 'A':
        alert( ' HREF: '+e.href);       
    }
  });
  
  </script>     
  </head>  
  <body>     
    <select name="top5" size="3">      
      <option>Heino
      </option>      
      <option>Michael Jackson
      </option>      
      <option>Tom Waits
      </option>      
      <option>Nina Hagen
      </option>      
      <option>Marianne Rosenberg
      </option>    
    </select>    
    <a href='#'>
      <img src="http://style.tutorials.de/lbxhottopics/1-4.jpg">A-TAG</a>  
  </body>
</html>

Dank im voraus.
 
Ändere mal das option-Tag so das es bei value den entsprechenden Wert enthält:

HTML:
<option value="Heino">Heino</option>

So bald dann wirklich ein Wert markiert ist, sollte es dann so angezeigt werden:

Javascript:
case 'SELECT': // IE
    alert( ' VALUE: '+e.value);
 
Leider bleibt es auch mit der Umstellung bei der Macke.

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'> 
  <head>    
  <title></title> 
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta http-equiv='Content-Language' content='de-DE' />    
  <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>  
  <script type="text/javascript">
 
  $(document).mousedown(function(event) {
    var e = event ? event.target : window.event;
    switch (e.tagName) {
      case 'SELECT': // IE
        alert( ' VALUE: '+e.value);
        break;
      case 'OPTION': //Firefox u. a.
        alert( ' TEXT: '+e.text);
        break;
      case 'IMG':
        alert( ' SRC: '+e.src);
        break;
      case 'A':
        alert( ' HREF: '+e.href);       
    }
  });
  
  </script>     
  </head>  
  <body>     
    <select name="top5" size="3">      
      <option value="Heino">Heino
      </option>     
      <option value="Michael Jackson">Michael Jackson
      </option>      
      <option value="Tom Waits">Tom Waits
      </option>      
      <option value="Nina Hagen">Nina Hagen
      </option>      
      <option value="Marianne Rosenberg">Marianne Rosenberg
      </option>    
    </select>    
    <a href='#'>
      <img src="http://style.tutorials.de/lbxhottopics/1-4.jpg" alt="Bild"/>A-TAG</a>  
  </body>
</html>

Ich habe nun festgestellt, dass der erste Wert immerhin angezeigt wird, wenn man die "SIZE"-Angabe weglässt:

HTML:
<html>  
  <head>    
    <title>
    </title>  
  <script type="text/javascript">
    function onMouseDown(e) {
      alert ("The selected option is " + e.value);
    }
  </script>
  </head>
  <body>    Select an item from the following list:<br />    
    <select onmousedown ="onMouseDown (this)">        
      <option value="Apple">Apple</option>         
      <option value="Pear">Pear</option>         
      <option value="Peach">Peach</option>     
    </select>
  </body>  
</html>

Wahrscheinlich mousedown einfach der falsch Event.
Ich denke, ich gehe auf click/selected value, wie ich es am Anfang mal hatte.
 
Zuletzt bearbeitet von einem Moderator:
Zurück