PDA

View Full Version : Cool DHTML Tooltip > new line breaks the code



lucadg
09-05-2007, 07:58 AM
Hi,
I am using the great Cool DHTML Tooltip
http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip.htm
but I have a small problem.

I found out that a text like this:


The flat is equipped with refrigerator, electric stove (upon request), electric kettle, dishes etc.
We would be happy to meet your train and show you personally to the flat. We may also arrange for you a transport from the airport (extra paid about 15 euro).

breaks the code because of the new line (when I remove it, it works).
I am retrieving this text from database with php and there seem to be no way to actually remove that new line.
I tried


$descriptionrest = addslashes(strip_tags(substr($description, $startmore, $maxlength)));
$descriptionrest = str_replace("\n", "", $descriptionrest); // this removes the line break which breaks the java tooltip
$descriptionrest =trim($descriptionrest);


A working example:
http://www.myapartments.eu/Apartments/Tallinn-old-town/3-bedroom-apartment-Old-Town-de-Lux-508.html

and a non working one
http://www.myapartments.eu/Apartments/Krakow-city-centre/1-bedroom-apartment-Rydla-337.html

I am using a function


function dhtmltooltip($text, $width)
{

$dhtmltooltip = "onMouseover=\"ddrivetip('$text', '$width')\" ; onMouseout=\"hideddrivetip()\"";



return $dhtmltooltip;
}



I am calling the function here:


if ( strlen($description) >= $desclength) { $descmore = "...(more) <img src=\"$server_root/images/arrowrightsm.gif\" border = 0 ".dhtmltooltip($descriptionrest, 300)." > ";}

else {$descmore = "";}

As I do not know Javascript, maybe there is an easy solution on the java side?
I am lost now :)
Thank you for your help!

Bye

Luca

jscheuer1
09-05-2007, 03:57 PM
Well, you may have to remove more than just the \n, sometimes a \r must also be removed to prevent a line from breaking.

It would probably be best to simply manually remove the line-break from the database.

lucadg
09-06-2007, 08:23 AM
Well, you may have to remove more than just the \n, sometimes a \r must also be removed to prevent a line from breaking.
and that was it! Thank you!
I wasn't even aware of the existance of |r:o


It would probably be best to simply manually remove the line-break from the database.
I have too many apartments to do that :)

Anyway, solved, thank you!

Luca