FCKeditor problem with value property that has quotes, apostrophes

Posted on 2005-05-13
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
    LVL 6

    Expert Comment


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

    Expert Comment

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

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

    Author Comment


    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.
    LVL 6

    Expert Comment

    LVL 20

    Accepted Solution

    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


    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

    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


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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved." Ralph Waldo Emerson Introduction: One of the wonderful things about the web is that it makes it s…
    In Part 1 ( we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
    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…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now