Click to See Complete Forum and Search --> : Anyone know why this only works 1X?


jookie
12-05-2003, 02:29 PM
I'm trying to create an expanding/collpasing menu for IE only. This works fine but only 1 time around, but errors out if u try again. Click on "load" and the hidden <div> appears. Click "unload" and it's gone. Try it again and nada. Any ideas? Thnx in adv...


<script>

function splat(vue){
this.vue = vue;
document.getElementById("load").style.display = vue;
}

</script>

<div id="main" style="width:400px; height:50px; border:1px solid #000000; padding:2px;">
<div id="controller">
<a href="#" onclick="splat('block'); empty.appendChild(load);">Load into shelf</a>
</div>
<div id="empty"></div>
<div id="bottom">
This is the bottom
</div>
</div>

<div id="load" style="height:100px; display:none;">
<a href="#" onclick="splat('none'); empty.removeChild(load);">Unload from shelf</a>
</div>

Pittimann
12-06-2003, 02:39 AM
Hi!

You could try something like that:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
function splat(whichdiv,vue){
this.vue = vue;
document.getElementById(whichdiv).style.display = vue;
document.getElementById(whichdiv).style.display = vue;
}
</script>
<div id="main" style="width:400px; height:50px; border:1px solid #000000; padding:2px;">
<div id="controller">
<a href="#" onclick="splat('load','block');splat('controller','none');">Load into shelf</a>
</div>
<div id="load" style="height:100px; display:none;">
<a href="#" onclick="splat('load','none');splat('controller','block');">Unload from shelf</a><br><br>some content
</div>
<div id="bottom">
This is the bottom
</div>
</div>
</body>
</html>

Assuming that you would like to display only the relevant link, I made the visibility of the two links toggle from hidden to visible...

Please note, that I removed the "empty" div and that I put 'some content' into the "load" div.

Cheers - Pit