Hallo,
ich habe eine Frage zu einem eigentlich recht einfachen
Javascript.
Vier Button horizontal nebeneinander, bei Klick auf einen der Button ändert sich die Farbe bzw. der Zustand. Soweit kein Problem.
Klickt man einen anderen Button an, springt der zuerst angeklickte in seinen Ursprungszustand und der zuletzt angeklickte ändert seinen Zustand. Auch noch kein Problem.
Hier zu sehen: http://www.ttams.de/scriptproblem/test.htm
Frage: Nun soll aber der erste Button beim ersten Aufruf der Seite bereits gehighlighted bzw. aktiv sein. Erst auf Klick auf einen der anderen solls wieder wie anfänglich beschrieben sein.
Hier das Script:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
var button1a = "b1.gif"
var button1b = "b1h.gif"
var button2a = "b2.gif"
var button2b = "b2h.gif"
var button3a = "b3.gif"
var button3b = "b3h.gif"
var button4a = "b4.gif"
var button4b = "b4h.gif"
var tempbutton = button1b;
var tempimage = button1a;
//-->
</script>
</head>
<body bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" topmargin="0" leftmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<br>
<table align="left" border="0" cellspacing="0" cellpadding="10" width="300">
<tr>
<td><a href="#" onClick="tempbutton.src=tempimage; tempbutton=b1; tempimage=button1a; b1.src=button1b;"><img name="b1" src="b1.gif" width="94" height="14" border="0" alt=""></a></td>
<td><a href="#" onClick="tempbutton.src=tempimage; tempbutton=b2; tempimage=button2a; b2.src=button2b;"><img name="b2" src="b2.gif" width="94" height="14" border="0" alt=""></a></td>
<td><a href="#" onClick="tempbutton.src=tempimage; tempbutton=b3; tempimage=button3a; b3.src=button3b;"><img name="b3" src="b3.gif" width="94" height="14" border="0" alt=""></a></td>
<td><a href="#" onClick="tempbutton.src=tempimage; tempbutton=b4; tempimage=button4a; b4.src=button4b;"><img name="b4" src="b4.gif" width="94" height="14" border="0" alt=""></a></td>
</tr>
</table>
</body>
</html>
Wer weiß Rat?
Danke und Gruß
Torsten