Lukas Böhm: Box has no properties

Beitrag lesen

Hi!
Ich habe das jetzt mal versucht umzusetzen, aber irgendwie klappt das noch nicht so ganz. Hier mal mein (jämmerlicher ;-)) Versuch:

<html>
<head>
 <title>Untitled</title>
<link rel="STYLESHEET" type="text/css" href="css.css">
<script type="text/javascript">
var lastOpenedBox = null;
function openBox(box){
    if(lastOpenedBox != null){
  closeBox(lastOpenedBox);
 }
 document.getElementById(box).style.display = "none";
    lastOpenedBox = box;
}
function closeBox(lastOpenedBox){
 document.getElementById(lastOpenedBox).style.display = "none";
}
</script>
</head>

<body>
<div class="topic"><a href="#" onclick="openBox(text1)">1.</a></div>
<div id="text1" class="text" style="display:none">
 1!Das sollte aufklappen!
</div>

<div class="topic"><a href="#" onclick="openBox(text2)">2.</a></div>
<div id="text2" class="text" style="display:none">
 2!Das sollte aufklappen!
</div>

<div class="topic"><a href="#" onclick="openBox(text3)">3.</a></div>
<div id="text3" class="text" style="display:none">
 3!Das sollte aufklappen!
</div>

<div class="topic"><a href="#" onclick="openBox(text4)">4.</a></div>
<div id="text4" class="text" style="display:none">
 4!Das sollte aufklappen!
</div>

<div class="topic"><a href="#" onclick="openBox(text5)">5.</a></div>
<div id="text5" class="text" style="display:none">
 5!Das sollte aufklappen!
</div>
</body>
</html>

Die JavaScript-Konsole meint, dass Box keine "properties" hat. Was muss ich machen, damit es funktioniert?
Vielen Vielen Dank!
szia, Lukas