Hello - I have this little script that generates a popup when an element is hovered. I'm trying to figure out how to have multiple elements, that each have their own popup.
In the referenced html file there are basically two elements. I've given them their own unique IDs in the HTML, but I have no idea how to add additional unique IDs in the JS, and make this sucker work. Currently, elements #1 and #2 both reveal the #1 popup. I'm trying to have #1 reveal the #1 popup, and #2 reveal the #2 popup.
I hope I've explained clearly.
<code>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS Multiple Test</title>
<script type="text/javascript">
function ShowPopup(hoveritem)
{
hp = document.getElementById("hoverpopup1");
// Set position of hover-over popup
hp.style.top = hoveritem.offsetTop + 18;
hp.style.left = hoveritem.offsetLeft + 20;
// Set popup to visible
hp.style.visibility = "Visible";
}
function HidePopup()
{
hp = document.getElementById("hoverpopup1");
hp.style.visibility = "Hidden";
}
</script>
</head>
<body>
<a id="hoverover1" style="cursor:default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();">Hover over me #1!</a>
<br>This is some<br>incidental<br>Text.
<div id="hoverpopup1" style="visibility:hidden; position:absolute; top:0; left:0;"><table bgcolor="#0000FF">
<tr><td><font color="#FFFFFF">This popup #1</font></td></tr>
<tr><td bgcolor="#8888FF">Hello I am popup table 1</td></tr></table>
</div>
<br />
<hr />
<a id="hoverover2" style="cursor:default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();">Hover over me #2!</a>
<br>This is some<br>incidental<br>Text.
<div id="hoverpopup2" style="visibility:hidden; position:absolute; top:0; left:0;"><table bgcolor="#00ccFF">
<tr><td><font color="#FFFFFF">This popup #2</font></td></tr>
<tr><td bgcolor="#cccccc">Hello I am popup table 2</td></tr></table>
</div>
</body>
</html>
</code>
In the referenced html file there are basically two elements. I've given them their own unique IDs in the HTML, but I have no idea how to add additional unique IDs in the JS, and make this sucker work. Currently, elements #1 and #2 both reveal the #1 popup. I'm trying to have #1 reveal the #1 popup, and #2 reveal the #2 popup.
I hope I've explained clearly.
<code>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS Multiple Test</title>
<script type="text/javascript">
function ShowPopup(hoveritem)
{
hp = document.getElementById("hoverpopup1");
// Set position of hover-over popup
hp.style.top = hoveritem.offsetTop + 18;
hp.style.left = hoveritem.offsetLeft + 20;
// Set popup to visible
hp.style.visibility = "Visible";
}
function HidePopup()
{
hp = document.getElementById("hoverpopup1");
hp.style.visibility = "Hidden";
}
</script>
</head>
<body>
<a id="hoverover1" style="cursor:default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();">Hover over me #1!</a>
<br>This is some<br>incidental<br>Text.
<div id="hoverpopup1" style="visibility:hidden; position:absolute; top:0; left:0;"><table bgcolor="#0000FF">
<tr><td><font color="#FFFFFF">This popup #1</font></td></tr>
<tr><td bgcolor="#8888FF">Hello I am popup table 1</td></tr></table>
</div>
<br />
<hr />
<a id="hoverover2" style="cursor:default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();">Hover over me #2!</a>
<br>This is some<br>incidental<br>Text.
<div id="hoverpopup2" style="visibility:hidden; position:absolute; top:0; left:0;"><table bgcolor="#00ccFF">
<tr><td><font color="#FFFFFF">This popup #2</font></td></tr>
<tr><td bgcolor="#cccccc">Hello I am popup table 2</td></tr></table>
</div>
</body>
</html>
</code>