Log in or register to post comments
Last post
Text Area Problem
Greetings,

I am creating a CMS for a website using ckeditor as the editor for pages. I am having a problem with putting textarea's inside inside of a page. I can insert textareas, but when i want to go back to that page to edit it, the editor glitches. It thinks that that the end of the editor is at the end of the embedded text area.

For example, if i were to put...
<textarea cols='80' id='"ckeditor"' name='"ckeditor"' rows='"20"'>
.....content... <textarea id="emailbody"></textarea>...content....
</textarea>

... it would think that the end of the email body textarea is the end of the ckeditor, which it is infact not.
This is what it looks like:
Image
The send mail and reset form button should be inside of the ckeditor.

Is there anyway around this?

Thanks,

Bricktop
Re: Text Area Problem
I have run into this same problem. I thought I could get around it by using a div tag for the editor but then when the form is submitted, the information in the div is not sent to the server obviously because it is not a form element. Any help would be greatly appreciated!
Re: Text Area Problem
The main problem seems to be that, generally, browsers do not render nested textareas (a textarea inside another textarea). CKEditor passes its content to a TEXTAREA (in your example it is the TEXTAREA named "ckeditor", so placing another TEXTAREA inside the CKEditor is already creating nested TEXTAREAS..

Try to run this code in your browser and see what happens: :?:
<html><body> 
<textarea id="a">
  test a
  <textarea id="b">
    test b
  </textarea>
</textarea> 
</body></html>

Personally, I would use a place holder, a substitute for the TEXTAREA code at design time, and add the TEXTAREA code later to the "finished product", after the email page was saved.
Re: Text Area Problem
The solution to this turned out to be quite simple. I use php to output my code and using the function:

htmlspecialchars()

on the content before sending it to the browser fixed the issue. An example would look like this:

<textarea class='editor' rows='10' cols='60'><?php echo htmlspecialchars($content); ?></textarea>


Another important command to run if you are pulling from MySQL is stripslashes()

<?php
$content = stripslashes($content);
$content = htmlspecialchars($content);
?>

<textarea class='editor' rows='10' cols='60'><?php echo $content; ?></textarea>



Hope this helps some people out!
Re: Text Area Problem
Yes, that may correct that issue, but correct me if im wrong, when outputting that code to page, the browser will not render it as html code, rather as just text. It will output "<textarea...>" rather then an actual textarea.
Re: Text Area Problem
When you output to the actual page ( the one a visitor would see, not the ckeditor page ) you use stripslashes() but not htmlspecialchars().

When you output to the edit page ( the one with ckeditor ) you use both stripslashes() and htmlspecialchars().

This is not just an idea, I am using it in a small CMS I wrote and everything is working as it should.
Re: Text Area Problem
works perfect! thanks blindmoe