Jump to content

escaping quotes in javascript


chronister

Recommended Posts

Hi Folks,

 

I am completely Javascript stupid and hope to find the time to learn someday. I am using a javascript tooltip from dynamic drive. http://dynamicdrive.com/dynamicindex5/dhtmltooltip2.htm

 

I am using this in conjuction with a php script that pulls a joke of the day from a database. I am having trouble with displaying the answers that have a ' or " in them. If I use stripslashes() and addslashes() I end up with the same problem as if I did not use them. Anyone have a suggestion as to how to get around this?

 

If you want to see it in action, go to http://home.happyjoes.net You will notice that today's joke does not popup on hover. That's because the answer is Because he had no "body" to go with !!

 

The code that creates the link and popup for the answer is here.

 

<a href="#" onMouseover="ddrivetip('<?=$answer ?>',400)"; onMouseout="hideddrivetip()" ><?=$question ?></a>

 

Thanks in advance.

 

Nathan Chronister

Link to comment
https://forums.phpfreaks.com/topic/59846-escaping-quotes-in-javascript/
Share on other sites

I manually went into the db and added the slashes and it still did not work. The real issue is that by the time the javascript grabs it and wants to display I don't want to display the slashes, so I will have the ' or " in the  code that it tries to display thereby breaking the script.

 

I guess if it comes down to it I will just use a different method to display the answer and not use the javascript tooltip popup.

 

Thank you for your answer I appreciate you taking the time to look at my issue.

 

Nathan Chronister

Archived

This topic is now archived and is closed to further replies.

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