FCKeditor problem with value property that has quotes, apostrophes

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.  
FrylockAsked:
Who is Participating?
 
virmaiorCommented:
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.
0
 
dgelinasCommented:

oFCKeditor.Value = "My ring\'\s on my finger";  
oFCKeditor.Value = "<font size='2'>hi</font>";  
0
 
archrajanCommented:
try this
oFCKeditor.Value ="My ring's on my finger";  

oFCKeditor.Value = '<font size="2">hi</font>';  
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
FrylockAuthor Commented:
Hi,

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.
0
 
dgelinasCommented:
thanks
0
 
FrylockAuthor Commented:

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.


0
 
FrylockAuthor Commented:
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?
0
 
virmaiorCommented:
str_replace("\n",'\n',$yourstring)

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

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.