Web www.gerd-tentler.de
Version 1.20 (released Jun. 11, 2009) [Download]

Usage

First include the script into your HTML body (not head!), preferably directly after the BODY tag:
<script type="text/javascript" src="richedit.js"></script>
Then create a new instance of the EDITOR class where you want the text field to appear. This would usually be inside a form:
var editor = new EDITOR();
You may wish to modify some settings:
editor.textHeight = 250;
editor.setFocus = true;
editor.fieldName = "htmlText";
...
Finally, create the text field:
editor.create();
If you want to create a text field with preloaded content, use this syntax instead:
editor.create(your_content);
Please note that your content may not include any CR or NL characters, or else you will get a JavaScript error. As already mentioned, you can create as many text fields as you want.

The contents of each text field can be accessed for instance with PHP after the form has been submitted. The text fields are named richEdit0, richEdit1, richEdit2, etc. You can change the field name richEdit either in the configuration section, or when creating a new instance of the richtext editor (see examples above). If you want to submit the contents of your text fields, you have to call the function rtoStore() first, for example by using a submit button like this:
<input type="submit" value="Submit" onClick="rtoStore()">
Or use a form like this:
<form action="..." onSubmit="rtoStore()">
You should also have a look at the source code of the introduction page and check out the sample page. ;-)

JS-RichEdit and PHP / MySQL

If you use the richtext editor with PHP and MySQL, there are some things to consider. I created a sample page where you can test the functionality and get the required infos. It is also included in richedit.zip, so you can have a look at the source code there.

Comments