John: Bildwechsel

Beitrag lesen

Sorry, ich hab in der Eile nur eine Code geschickt, heir sind jetzt beide:
<html>
<head>
<title>
Bildewechsel
</title>
<script language="JavaScript">
var Rechnung;
var Zahl=3;
var Bild;

Sport1 = new Image();
Sport1.src = "S1.bmp";

Sport2 = new Image();
Sport2.src = "S2.bmp";

Sport3=new Image();
Sport3.src="S3.bmp";

Sport4=new Image();
Sport4.src="S4.bmp";

Sport5=new Image();
Sport5.src="S5.bmp";

function Zahlplus()  {
Zahl++;
Bild="Sport"+Zahl;
document.images[0].src=Bild;
}

function Zahlminus()  {
Zahl=Zahl-1;
Bild="Sport"+Zahl;
document.images[0].src=Bild;
}

</script>
</head>

<body>
<img src="S3.bmp">
<form name="Button">
<input type=button value=links onClick="Zahlminus()">
<input type=button value=rechts onClick="Zahlplus()">
</form>
</body>
</html>

Oder vielleicht so

<html>
<head>
<title>
Bildewechsel
</title>
<script language="JavaScript">
var Rechnung;
var Zahl=3;
var Bild;

Sport1 = new Image();
Sport1.src = "S1.bmp";

Sport2 = new Image();
Sport2.src = "S2.bmp";

Sport3=new Image();
Sport3.src="S3.bmp";

Sport4=new Image();
Sport4.src="S4.bmp";

Sport5=new Image();
Sport5.src="S5.bmp";

function Zahlplus()  {
Zahl++;
if(Zahl==6)  {
Zahl==1;
}
if(Zahl==1)  {
document.images[0].src=Sport1;
}
if(Zahl==2)  {
document.images[0].src=Sport2;
}
if(Zahl==3)  {
document.images[0].src=Sport3;
}
if(Zahl==4)  {
document.images[0].src=Sport4;
}
if(Zahl==5)  {
document.images[0].src=Sport5;
}
}

function Zahlminus()  {
Zahl=Zahl-1;
if(Zahl==0)  {
Zahl==5;
}
if(Zahl==1)  {
document.images[0].src=Sport1;
}
if(Zahl==2)  {
document.images[0].src=Sport2;
}
if(Zahl==3)  {
document.images[0].src=Sport3;
}
if(Zahl==4)  {
document.images[0].src=Sport4;
}
if(Zahl==5)  {
document.images[0].src=Sport5;
}
}
</script>
</head>

<body>
<img src="S3.bmp">
<form name="Button">
<input type=button value=links onClick="Zahlminus()">
<input type=button value=rechts onClick="Zahlplus()">
</form>
</body>
</html>