Solved

dynamic content pop up

Posted on 2004-09-25
7
282 Views
Last Modified: 2013-11-28
hi i don't know if this would be the right section to ask this question cos it sounded more JS then php.

I have afew links of vessel name. i want to be able to move my mouse over it and a pop up will appear showing me details of the vessel.
the detail are extracted from mysql.
The pop up willl close when i move my mouse away from the link.

please help
0
Comment
Question by:mysticaljoey
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 27

Expert Comment

by:Diablo84
ID: 12149939
Use a script like this one (http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip.htm) to handle the tooltip pop up then when you call the script you can do this:.

This is the example of a static link with a tool tip (from the link):

<a href="http://site.com" onMouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onMouseout="hideddrivetip()">Link</a>

To make it dynamic, you could do this:

<?php
$conn = mysql_connect("host","username","password") or die(mysql_error());
mysql_select_db("db_name",$conn) or die(mysql_error());

$query = "SELECT * FROM tablename";
$query = mysql_query($query) or die(mysql_error());

//now you have the results returned from the query you can use various methods to
//output them example: taking a field from the first row returned

$output = mysql_result($query,0,"field_name");
?>

<a href="http://site.com" onMouseover="ddrivetip('<?php echo $output; ?>','yellow', 300)" onMouseout="hideddrivetip()">Link</a>
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 12149943
Here are two references to the manual that you will need for information about outputting the results returned from the query:

http://www.php.net/manual/en/function.mysql-result.php

and:

http://www.php.net/manual/en/function.mysql-fetch-assoc.php

Both include examples of use.
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 12154106
As quite a lot of browsers support popupblocking, you could consider using absolute positioned popup divs instead. These are hidden and will be shown using javascript. Another things is that these kind of webpages can easily be generated using php/mysql.

regards

-r-

example:  (vesseldetails-divs are not absolutely position yet, but this example just shows hiding/unhiding)

<html>
<head>
<script type="text/javascript">
function showDetails(detailid)
{
  var elems = document.getElementsByTagName('div');
  for(i = 0; i < elems.length; i++)
  {
     if(elems[i].className == 'vesseldetails')
     {
         elems[i].style.display = (elems[i].id == detailid ? '' : 'none');
     }
  }
  return false;
}
</script>
</head>
<body>
<div><button onclick="return showDetails('ves1');">Vessel 1</button></div>
<div><button onclick="return showDetails('ves2');">Vessel 2</button></div>
<div><button onclick="return showDetails('ves3');">Vessel 3</button></div>
<div class="vesseldetails" id="ves1" style="display:none;">v1</div>
<div class="vesseldetails" id="ves2" style="display:none;">v2</div>
<div class="vesseldetails" id="ves3" style="display:none;">v3</div>
</body>
</html>
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 9

Expert Comment

by:_GeG_
ID: 12158314
you can use plain css to accomplish that, without an scripting, see
http://www.madaboutstyle.com/tooltip2.html
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 12158344
As it concerns a popup with possible some interactive content, or content which users might want to copy, css is a nice solution, but not sufficient as the popup disappears when you want to move your mouse onto it.

-r-
0
 
LVL 9

Expert Comment

by:_GeG_
ID: 12158392
[quote]...to move my mouse over it and a pop up will appear showing me details of the vessel.
the detail are extracted from mysql.
The pop up willl close when i move my mouse away from the link.[/quote]
CSS is perfect for those requirements.
using the madaboutstyle example, tha code would look like
<?php
while ($row=mysql_fetch_row($result)){
    echo "<a href=\"{$row['link']}\" class="info">{$row['name']}<span>{$row['details']}</span></a><br>\n";
}
0
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 500 total points
ID: 12161552
You could always use OverLib as well:
http://www.bosrup.com/web/overlib/

It's pretty flexible in what it can do.

- Jonathan
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What does != "" mean in programming 8 80
How to fix Datetime in MySQL? 4 49
Wordpress Security 29 48
Could you point a way to eliminate an array unexpected element? 8 24
This article discusses four methods for overlaying images in a container on a web page
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The viewer will learn how to count occurrences of each item in an array.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question