Andreas: Radiobuttons und Event-Handler?

Beitrag lesen

Hi,

okay, ich versuchs' nochmal...:

<html>
<head>
<style type="text/css">
<!--
 .antwort {background-color:blue;
    color:white;
    font-weight:bold;
    font-family:Arial;
    font-size:12;}
-->
</style>
<script language="javascript">
function antwort(){
  if(document.formular.auswahl[0].checked){
    document.getElementById('antwort1').style.backgroundColor='red';
    document.getElementById('antwort2').style.backgroundColor='blue';
  }else{
    document.getElementById('antwort1').style.backgroundColor='blue';
    document.getElementById('antwort2').style.backgroundColor='red';
  }
}
</script>
</head>
<body>
<form name="formular">
<input name="antwort1" id="antwort1" class="antwort" size=25><br>
<input name="antwort2" id="antwort2" class="antwort" size=25><br>
<input type="radio" name="auswahl" value="a1" onclick="antwort()">1<br>
<input type="radio" name="auswahl" value="a2" onclick="antwort()">2
</form>
</body>
</html>

Das hat zu funktionieren.

Ciao
Andreas