Click to See Complete Forum and Search --> : Passing-in Values Then Changing


SearedIce
06-12-2003, 02:57 PM
Here's the script/html code:

<html>
<head>
<title>Menu Test</title>
<script langauge="javscript">
var whichmenu;
function bringDown(whichmenu)
{
document.???????????.style.visibility = "visible";
}
</script>
</head>
<body>
<div onMouseOver="bringDown(1);" style="border: solid #000000 1px; position: absolute; top: 10px; left: 10px; width: 100px; height: 20px">
HAHAMENU1
</div>
<div onMouseOver="bringDown(2);" style="border: solid #000000 1px; position: absolute; top: 10px; left: 110px; width: 100px; height: 20px">
HAHAMENU2
</div>
<div id="popdown1" style="border: solid #000000 1px; position: absolute; top: 30px; left:10px; width: 50px; height: 20px; visibility: hidden">
POPDOWN1
</div>
<div id="popdown2" style="border: solid #000000 1px; position: absolute; top: 30px; left:60px; width: 50px; height: 20px; visibility: hidden">
POPDOWN2
</div>
</body>
</html>

See the ????????? ?

Well...given either the number of menu div or name of menu div passed into the function from the onMouseOver, how can I change the correct menu thing to be visible

Yes, I know I could make a bunch of If statements to pick which menu to change but I want to be able to add any number of "menus" and not have to worry about copying the code for each menu (in case I want to make a change to all of them later but by then I have like 20 "menus")

please help,
John

gil davis
06-12-2003, 03:06 PM
document.getElementById("popdown" + whichmenu).style.visibility = "visible";

SearedIce
06-12-2003, 03:08 PM
sweet, thanks!

where do you guys learn all these wild javascript functions?

scriptkid
06-12-2003, 03:08 PM
bringDown(this) <---in your mouseoverstatement
then do

function bringDown(whichmenu)
{
document.whichmenu.style.visibility = "visible";
}

SearedIce
06-12-2003, 03:16 PM
nah...that's not working

scriptkid
06-12-2003, 03:30 PM
meant this.id

SearedIce
06-12-2003, 04:38 PM
nope, still not working...ie is looking for something with id="whichmenu" still lol

the other way with getElementById works fine though :)

here's what i have so far:

http://www14.brinkster.com/drakej/menutest.html

Jona
06-12-2003, 06:29 PM
Scriptkid, you would have to use the eval() method for that; otherwise the only browser that might interpret it correctly, would be IE.

Jona

SlankenOgen
06-13-2003, 11:40 AM
For IE use

var z = ["popdown"+whichmenu];

document.all[z].style.visibility = "visible";


For Nutscrape + IE you can use-

var z = ["popdown"+whichmenu];

document.getElementById(z).style.visibility = "visible";


~mgb

SearedIce
06-13-2003, 02:01 PM
haha nutscrape!

thanks for the help guys

diehard ie fan,
john

SlankenOgen
06-13-2003, 02:32 PM
I don't even write stuff for Nutscrape anymore. I wish they'd go away and let us in peace!

~mgb