Bild in ein Panel einfügen

Statcher

Mitglied
Hallo,
ich habe hier ein Zahlenraten Spiel programmiert.
Code:
<html>
<head>
<<meta charset="UTF-8">
<title>Zufallszahl</title>
<script type="text/javascript">
    function newGame(){
        document.zufall.zahl1.value = Math.floor(Math.random() * 100);;
    }
   
    function raten(){
        var zufall = document.zufall.zahl1.value;
        var zahl = document.zufall.zahl2.value;
        if(zufall == zahl){
            window.alert("Juhhuuuu! Sie haben die Zahl erraten!")
            document.zufall.colorPanel.style.backgroundColor = 'green';
        }
        if(zufall > zahl){
            window.alert("Die Zahl ist zu klein!");
            document.zufall.colorPanel.style.backgroundColor = 'blue';
        }
        if(zufall< zahl){
            window.alert("Die Zahl ist zu groß!")
            document.zufall.colorPanel.style.backgroundColor = 'red';
        }
    }
</script>
</head>
<body>

<br><br><br><center><h1> Raten Sie die Zahl! (Zwischen 1 und 100) <h1></center><br><br><br>

<center>
<form name="zufall">
<input type="hidden" name="zahl1"> <br>
<input type="text" name ="zahl2"> <br>
<input type="button" value="raten" onclick="raten();"> <br>
<input type = "button" value="neues Spiel" onclick ="newGame();">  <br> <br>
<input name = "colorPanel" style="height: 100px; width: 200px;">
<input name="picturePanel" style="height: 100px; width: 200px;"> <br>


</form>
</body>
</html>

Ich würde gerne in das "picturePanel" nach jeder if ein anderes Bild einfügen.
Nur leider weiß ich nicht wie ich dort ein Bild einfügen soll.
Könnt ihr mir das helfen?
 

Thallius

Top Contributor
Versuch es doch einfach mal mit

Code:
document.zufall.picturePanel.innerHTML("<img src=....");

... dann bitte entsprechend vervollständigen.

Gruß

Claus
 

Ähnliche Java Themen

Neue Themen


Oben