View Full Version : DDRivetip and css

09-10-2012, 03:47 AM
1) Script Title: DHTML tooltip script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip.htm (http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip.htm)

3) Describe problem: I would like to control the appearance of each line in the popup. When I try to include styling, the tip is displayed on the page, as opposed to a popup. Here is an example of what I am trying to do:
$color = '#00ff00';
$width = 300;
$contents = '<span style="color:red;">Line 1</span>';
$contents .= '<span style="color:white;">Line 2</span>';
$contents .= '<span style="color:blue;">Line 3</span>';

<td><?php echo '<a onMouseover="ddrivetip(\'' . $contents . '\',\'' . $color . '\',\'' . $width . '\' )"; onMouseout="hideddrivetip()"href="' . $file_name . '" target="_blank">' . $file_name . '</a>'; ?></td>
When I refresh the page, it displays
Line 1Line 2Line 3','#00ff00','' )"; onMouseout="hideddrivetip()"href="" target="_blank">So it seems the <> are getting lost. Am I doing something wrong or is this not possible? For what its worth, I can use <font></font> to change the font size and it works fine.

09-13-2012, 02:20 AM
Just an update. This still fails but I've found that if i use <div></div> with no styling that code acts as normal. So it isn't the brackets like I thought. Seems to be the actual css. I'm surprised no one is able to find a solution for this. I would think using css would be quite common.

09-13-2012, 02:45 AM
I don't think that's a problem. It's probably the PHP. Er, rather the markup, script and styles the PHP creates. But basically the PHP.

Use the browser's 'view source' to see the served content. That might help you see the problem.

On the other hand, it might have nothing to do with PHP. See if you can reproduce the problem without PHP.

If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.

09-13-2012, 03:02 AM
Also, try it out without the concatenation, and just type it into the outputting string.

09-13-2012, 03:55 AM
Concatenation has nothing to do with it. I tried out the PHP code in your post and it is the problem. Replace:

$contents = '<span style="color:red;">Line 1</span>';
$contents .= '<span style="color:white;">Line 2</span>';
$contents .= '<span style="color:blue;">Line 3</span>';


$contents = htmlspecialchars('<span style="color:red;">Line 1 </span>');
$contents .= htmlspecialchars('<span style="color:white;">Line 2 </span>');
$contents .= htmlspecialchars('<span style="color:blue;">Line 3 </span>');

and it works fine. Alternatively you could instead use:

$contents = '<span style=\\\'color:red;\\\'>Line 1 </span>';
$contents .= '<span style=\\\'color:white;\\\'>Line 2 </span>';
$contents .= '<span style=\\\'color:blue;\\\'>Line 3 </span>';

10-15-2012, 01:55 AM
John - Thank you very much for posting the solution. I got pulled away on another product and couldn't respond until now but i didn't want you to think your reply was not appreicated. Your solution worked perfectly. Thank you. :)