krimgelas wrote:
[color=blue]
> I was hoping that I could do it without a cookie (b/c then I also have to
> assume that cookies are on) by passing a variable to the script through the
> URL, like
http://index.php?...&open=true or something like that. I
> suppose that amounts to the same thing.[/color]
Yes, the idea behind is the same.
[color=blue]
>I am stuck on the part where the
> menu expands based on the value of a variable on page load, b/c right now
> the function only responds to an onClick event.
>
> So I have something like this, but don't know what to do with the variable
> "open" in the javascript function.
>[/color]
Ok, here is a working draft based on the code you provided.
You may want to modify it according to your needs.
Especially accordingly to the php querystring you're going to use: the init
function, as is, works only if you have no more than 9 categories.
Attach the init function to an onload event:
function init() {
if (!document.getElementById) return;
var i = location.search.indexOf("open=");
if (i != -1) {
var value = location.search.charAt(i+5);
toggleMenu('menu'+value);
}
}
function toggleMenu(currMenu) {
if (document.getElementById) {
thisMenu = document.getElementById(currMenu).style;
thisMenu.display = (thisMenu.display == "block") ? "none" : "block";
}
return false;
}
[color=blue]
> function toggleMenu(currMenu,open) {[/color]
[snip]
[color=blue]
> }
>
> <a href="index.php" onClick="return toggleMenu('menu1')">Gallery</a>
>
> <span id="menu1">[/color]
^^^^^^^^^^^^^^^^^ The use of a <list> would be better. Add
style="display:none" if you want toggleMenu to work.
[color=blue]
> <a href="index.php?category=1&open=1>Category1</a>
> <a href="index.php?category=2&open=1>Category2</a>
> <a href="index.php?category=3&open=1>Category3</a>
> </span>
>
> Kris[/color]
--
Riccardo