1
<!DOCTYPE html>
<html>
<head>
<title>Javascript</title>
</head>
<script>
function auswahl() {
Ton1 = document.getElementById("mySelect").value;
document.getElementById("demo").innerHTML = "Der erste Ton ist: " + Ton1;
Ton2 = (document.Tonleiter.Ton2.value);
Ton3 = (document.Tonleiter.Ton3.value);
Ton4 = (document.Tonleiter.Ton4.value);
Ton5 = (document.Tonleiter.Ton5.value);
Ton6 = (document.Tonleiter.Ton6.value);
Ton7 = (document.Tonleiter.Ton7.value);
}
function prüfen() {
document.getElementById("mc").onclick;
if (Ton2 =='' || Ton3 =='' || Ton4 =='' || Ton5 =='' || Ton6 =='' || Ton7 ==''){
alert("Bitte alle Felder ausfüllen.");
} else if (Ton2 =='d' || Ton3 =='e' || Ton4 =='f' || Ton5 =='g' || Ton6 =='a' || Ton7 =='h') {
alert("Alles Richtig.");
} else { alert("mindestens ein Ton ist falsch");
}}
</script>
<body>
<select id="mySelect" onchange="auswahl()">
<option value="Auswahl">Auswahl</option>
<option value="c">c</option>
<option value="d">d</option>
<option value="e">e</option>
<option value="f">f</option>
<option value="g">d</option>
<option value="a">e</option>
<option value="h">f</option>
</select>
<p id="demo"></p>
<label>Ton 2: </label>
<input type="text" name="Ton2" size="2">
<label>Ton 3: </label>
<input type="text" name="Ton3" size="2">
<label>Ton 4: </label>
<input type="text" name="Ton4" size="2">
<label>Ton 5: </label>
<input type="text" name="Ton5" size="2">
<label>Ton 6: </label>
<input type="text" name="Ton6" size="2">
<label>Ton 7: </label>
<input type="text" name="Ton7" size="2">
<input type="button" value="check" id="mc" onclick="prüfen()">
</body>
</html>
[Edit Jörg: Code-Block eingfügt]