Search code examples
javascriptphpckeditor

How to insert value html from database into javascript with php for CKEDITOR?


I want to make edit topic , and for this i need to select data from database ( this data is insert from ckeditor with html tag) I have already done the data selection and storage function in this mode:

$getContentTopic = $this->getForumFunctions()->getContentTopic($_GET['tid']);

And the javascript code for ckeditor and replace the value i have like that:

<script>
    CKEDITOR.replace( 'comment' );
    CKEDITOR.instances['comment'].setData('<?php echo $getContentTopic; ?>');

</script>

If the value of $getContentTopic is just text , it worked , displayed the text value inside of ckeditor .. but if is html tag i have this error:

Uncaught SyntaxError: Invalid or unexpected token

For exemple my $getContentTopic have this value

Bla bla

doesn't work, but if have value Test it works.


Solution

  • I resolve this.. just add inside of tag <textarea></textarea> date from database .. for my form I added so

    <textarea name="comment" ><?php echo $getContentTopic; ?></textarea>