Forum Moderators: open

Message Too Old, No Replies

Help with javascript menu needed

         

Skyliner

8:30 pm on Sep 28, 2006 (gmt 0)

10+ Year Member



Hi,

I have a javascript menu that opens a box, once I click on a link:

<a href="javascript:toggle('window1')" class="links">Test</a> <=thi is the link

<span id="window1">Window1</span> <=this is the box/window that opens

<script type="text/javascript">
document.getElementById('Window1').style.display="none";
function toggle(Window1){
var listElementStyle=document.getElementById(Window1).style;
if (listElementStyle.display=="none"){
listElementStyle.display="block";
}
else{ listElementStyle.display="none";
}
}
</script>

The problem is that once a window is open, it stays open, until the link is clicked again. I plan to use multiple boxes like these on one page, but I only want one window/box to be open at a time. I believe, the best solution would be to simply close all other boxes, once you open a respective box.

Unfortunately, I don't know much about javascript, so your help would be greatly appreciated.

Fotiman

8:45 pm on Sep 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You might try looking into the Yahoo UI Library [developer.yahoo.com]'s Container [developer.yahoo.com] family. This includes the Dialog [developer.yahoo.com]. This might do exactly what you want because it makes the dialogs modal (that is, the rest of the page is "faded" out, until you clear the dialog).

Alternatively, you would need to store all of your dialog windows in an array.

Skyliner

10:47 pm on Sep 28, 2006 (gmt 0)

10+ Year Member



I've found a solution.

Thanks for your help.