Jump to content

This is JS but Mainly a PHP Problem, Please help!


Marsha

Recommended Posts

Hey

The problem is, I have a JS script for Hover over buttons, which adds information in a little table when you hover over some text, I have a php script which sets out 4 different title names from MySQL.

 

I have entered the JS into the PHP correctly and It works but Only for One of the title names, I want each title to show each description also from MySQL

 

So, you go onto the page, and there are 4 different titles, collected from MySQL, I hover over the first title and it comes up with the description perfectly, but all the other titles come up with the description of the first one.

 

Code is below :)

JS CODE

<script type="text/javascript">

function ShowPopup(hoveritem)

{

hp = document.getElementById("hoverpopup");

 

// Set popup to visible

hp.style.visibility = "Visible";

}

 

function HidePopup()

{

hp = document.getElementById("hoverpopup");

hp.style.visibility = "Hidden";

}

</script>

Body Code

echo '<td align="center"><a id="hoverover"

 

style="cursor:default;" onMouseOver="ShowPopup(this);"

 

onMouseOut="HidePopup();">',$row['title'],'</a><br />';

 

echo '<body><div id="hoverpopup" style="visibility:hidden; position:absolute;

 

z-index:1; top:300; left:20; height: 71px; width: 99px">' . $row['description'] . '</div></body>';

$row['title'] = Title

$row['description'] = Description

If your fetching multiple records from a db you could create an unique id for div element something like:

 

<?php for($i=0; $i<sizeof($records); $i++ ): ?>
  <a onMouseOver="ShowPopup('hoverpopup<?php echo $i; ?>');" onMouseOut="HidePopup('hoverpopup<?php echo $i; ?>');">link</a>
  
  <div id="hoverpopup<?php echo $i; ?>">
    <!-- popup stuff -->
  </div>
<?php endfor; ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.