FCKeditor problem with value property that has quotes, apostrophes

Posted on 2005-05-13
Medium Priority
Last Modified: 2008-08-07
I need the value property to be able to display content that has both single (apostrophe - ' ) and double qoutes - " ).  
What I am doing is echoing from php into value property content that includes both ' and ".  
However, the java gets escaped from with the ' or the " depending on which one I use to set the oFCKeditor.Value.  
' causes problems with  
oFCKeditor.Value = 'My ring's on my finger' ;  
The " causes problems with
oFCKeditor.Value = '<font size="2">hi</font>";  
Any help would be appreciated. I did a search and could not find any other answers to this.  
Question by:Frylock
  • 3
  • 2
  • 2
  • +1

Expert Comment

ID: 13997806

oFCKeditor.Value = "My ring\'\s on my finger";  
oFCKeditor.Value = "<font size='2'>hi</font>";  
LVL 25

Expert Comment

ID: 13997821
try this
oFCKeditor.Value ="My ring's on my finger";  

oFCKeditor.Value = '<font size="2">hi</font>';  

Author Comment

ID: 13997867

The problem is that the value property is being pulled from a db and is being echoed. EG:

The var_text = <font="2">My Mom's ring is in the box.</font>

Now, when I echo that into the value this way:

oFCKeditor.Value = "<? echo $var_text ; ?>" ;

The server sends:

oFCKeditor.Value = "<font="2">My Mom's ring is in the box.</font>";

Swapping the " for a ' doesn't help because both are used in the string.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 13997898
LVL 20

Accepted Solution

virmaior earned 2000 total points
ID: 13998243
you should use the php function addslashes() to the value you are echoing into the JavaScript.
or alternately just do a str_replace("\","\'",$your_string)

The JavaScript problem you're experiencing is more symptom than cause.

Author Comment

ID: 13998716

I put in the 'addslashes' to the echo'd variable, but it is still tripping up on it.

Here is what the source of the page shows:

oFCKeditor.Value = '<p>He said to the woman, &quot;Who is your favorite singer?&quot;</p><p>She responded, after looking at her mother\'s watch, &quot;Shirley Manson\'s voice is spectacular.&quot; </p>' ;

It is still being broken.


Author Comment

ID: 14000201
HEy Virmajor - it's the line break that is killing it now.There are two or three of them and the line breaks kill it. How can I get rid of them?
LVL 20

Expert Comment

ID: 14000441

alternately: str_replace("\n",'<br />',$youstring);
(the former will cause JavaScript to reinterpolate the line breaks, the latter will cause the same effective appearance).

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question