Jump to content

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


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; ?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.