PDA

View Full Version : A question about "Cool DHTML Tooltip"



CaseyC
01-11-2011, 10:32 PM
1) Script Title: Cool DHTML Tooltip

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

3) Describe problem:
My website displays in three different languages. A routine selects the appropriate language text string, places it into a variable and cranks up the display routine.

Is it possible to use a variable instead of the 'text string' with this script. If so, do I just enter it aws '$variable'?????

Thanks.

djr33
01-12-2011, 12:51 AM
This should be possible. What programming language are you using for these variables? The $ makes me think that it is PHP.

CaseyC
01-12-2011, 01:59 AM
This should be possible. What programming language are you using for these variables? The $ makes me think that it is PHP.

Thank you for the quick reply.

I have a PHP routine that holds all of the text declarations, one file for each language.

My text statement in the English file looks like this:

$text ['hlp_home'] = "Home - Takes you to the front page of the this website.";

There is an equivalent in Spanish and German each in its own language file.

The routine that uses this is HTML with some PHP in line. I modded the statement to test the tooltip, it works as advertised and looks like this:

<img border="0" src="img/tng_home.gif" align="middle" width="20" height="20" onMouseover="ddrivetip('Click to return to home page')";
onMouseout="hideddrivetip()">

I solved something similar to this, by putting the entire HTML statement into a text string, and I got that to work. It looks like this:

$text ['menupic'] = "<img border=\"0\" src=\"img/AncChrtMiniUSA.jpg\" width=\"744\" height=\"669\">";

I added this code to the HTML file and it works.

<?php
echo $text['menupic'];
?>

When I tried to use this approach with the function in the statement, all I got was the text string printed out.

Any suggestions would be greatly appreciated.

Thank you,
Klaus Dieter Cook
Houston, Texas

djr33
01-12-2011, 05:07 AM
You will need to generate the Javascript using PHP, by echoing that variable where the string will be for the Javascript. It will be something like this:

var stringname = '<?php echo $text['mytext']; ?>';

Of course this means including this part of the Javascript within the page's code rather than in an external .js file.

CaseyC
01-12-2011, 04:41 PM
Thank you Daniel. While I was waiting, I played around some more with the method of declaring the entire HTML statement as a text string in my individual language folders. I finally got it to work. My "expertise" in php was at fault. I had originally included escape characters (\) for all the quotes AND the single quotes in the text string. Once I removed the back slash from the single quote it worked.

Again, thank you for your expertise.......if you ever need to solve a problem in ASM or Fortran, feel free to ask.....lol.......I am showing my age here.

Mit freundlichen Grüßen von Houston, TX
Klaus Dieter Cook
Houston, Texas