Jump to content

Recommended Posts

Hello. First off, my experience with merging JS+PHP is minimal, so this may be an easy fix (or maybe I screwed something up beyond fixing). I've been looking for fixes to no avail, I would greatly appreciate any help.

 

What I'm trying to do is create a tooltip that loads data via a MYSQL connection, displayed through PHP. I am using coolTips (JS) for the custom popup effect.

 

Here is my code for an anchor that opens the tooltip;

<?php 

$description = "<span class=\'ldescription\'>" . addslashes("$row[18]") . "</span>";

echo "
<a href=\"javascript:void(0);\" onclick=\"return coolTip('$description', WIDTH, 430, HEIGHT, 230, OTHER MISCELLANEOUS PARAMETERS); return true;\" onmouseout=\"nd(); return true;\">$row[1]</a>
";
?>

 

My problem occurs when there are double quotes (") in $description. Addslashes fixed the single quote (') problem, but when there are double quotes they end the anchor tag (it shows everything as a hyperlink from the end of $description to the beginning of the anchor closing tag).

 

Again, I'd greatly appreciate any help on this.

Link to comment
https://forums.phpfreaks.com/topic/84313-quote-woes-with-phpjs/
Share on other sites

It seems easier to troubleshoot this sans the whole database connection, variables,  etc...

 

<?php echo "
<a href=\"javascript:void(0);\" onclick=\"return coolTip('<div id=\'ctInside\'>SAMPLE TEXT</div>, SOME PARAMETERS'); return true;\" onmouseout=\"nd(); return true;\">link</a>
";

 

I just have some text (SAMPLE TEXT), inside an onclick (coolTip), inside an echo. How do I escape double quotes in this scenario? (If SAMPLE TEXT were SAM"PLE TEXT).

Link to comment
https://forums.phpfreaks.com/topic/84313-quote-woes-with-phpjs/#findComment-430391
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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