PDA

View Full Version : simple function not working


mattover-matter
04-17-2003, 11:54 PM
I am working on a dropdown menu, and this "simple" function is driving me mad.


<html>
<head>
<title>Home</title>
<style type="text/css">
body {
background-color: #000000;
background: url("stars.gif");
color: #45aeff;
margin: 0px;
margin-top: 10px;
scrollbar-base-color: #222222;
scrollbar-arrow-color: #45aeff
}

a {
text-decoration: none;
font-size: 12px;
width: 100;
height: 26;
position: relative;
top: 7px;

}

a:link, A:visited {
color: #45aeff
}

a:hover {
color: #ffffff
}

a:active {
color: #cccccc
}

table, td {
margin: 0px;
border-collapse: collapse;
padding: 0px;
}
</style>
<script language="text/javascript">
function showmenu('div', 'cell'){
div.style.visibility=visible;
cell.style.background=url("menu-background-highlight.gif");
}
</script>
</head>
<body>
<table width="100%">
<tr>
<td background="menu-background.gif">&nbsp;</td>
<td align="center" id="linkcell1" width="100" background="menu-background.gif"><A href="#" onmouseover="showmenu('dropdown1', 'linkcell1')">Link</a></td>
<td background="menu-background.gif">&nbsp;</td>
<td align="center" id="linkcell2" width="100" background="menu-background.gif"><A href="#">Link</a></td>
<td background="menu-background.gif">&nbsp;</td>
<td align="center" id="linkcell3" width="100" background="menu-background.gif"><A href="#">Link</a></td>
<td background="menu-background.gif">&nbsp;</td>
<td align="center" id="linkcell4" width="100" background="menu-background.gif"><A href="#">Link</a></td>
<td background="menu-background.gif">&nbsp;</td>
<td align="center" id="linkcell5" width="100" background="menu-background.gif"><A href="#">Link</a></td>
<td background="menu-background.gif">&nbsp;</td>
<td align="center" id="linkcell6" width="100" background="menu-background.gif"><A href="#">Link</a></td>
<td background="menu-background.gif">&nbsp;</td>
</tr>
</table>

<div id="dropdown1" style="visibility: hidden;">
some more text
</div>
text
<EMBED src="music.mp3" width="144" height="60" autostart="true" loop="true" hidden="true">
</body>
</html>

i want it to onmouseover show the div and change the background. Why won't it work?

A1ien51
04-18-2003, 01:53 AM
first off you have quotes where it should be a var

showmenu('div', 'cell'){
should be
showmenu(div, cell){

Second off, you are not going to be able to show and hide stuff like that.

Look at the code on the following link and see if it helps you out

http://www10.brinkster.com/a1ien51/JavaRanch/showhidetoggle.htm

A1ien51

beetle
04-18-2003, 01:54 AM
Well

1) You incorrectly declare you receipt parameters as strings
2) You try to access the element represented by the ID you try to pass into those bad parameters incorrectly
3) Style rules are applied as strings. Not just part, but the entire value.
4) Unless you are setting other attributes, it's more proper to use backgroundImage

function showmenu( divId, cellId )
{
document.getElementById( divId ).style.visibility = 'visible';
document.getElementById( cellId ).style.backgroundImage = 'url(menu-background-highlight.gif)';
}I'd just like to interject that a script as complicated as a dropdown menu system isn't the best project for a novice. They can be quite complicated

mattover-matter
04-18-2003, 02:17 AM
I am sorry guys, I really do not know. I tried changing the smallest things and using what u guys gave me, but still nothing worked. a1ien, I do not understand. Our scripts looked similar, except u just had some if/then/else statements. I'm sorry if I frustrate you.

beetle, I do not see how it can be that complex, I just show a div and do some math. I got this all planned in my head, just need help with some coding.

I tried just calling it from a button and making it as simple as possible:

function showmenu(divId){
document.getelementbyId(divId).style.visibility = 'hidden';
}

Sorry for all the trouble.

beetle
04-18-2003, 02:33 AM
mattover,
I don't the time to divulge the specifics, but if that's all you think is involved, then I wish you the best of luck.

mattover-matter
04-18-2003, 03:25 AM
well, we'll see if it comes out :D