Bookmark to del.icio.us
Rich Text Editor (for textareas)
Description: Replace a form's textarea field(s) with a custom one that supports WYSIWYG formatting with this Rich Text Editor script. It allows the user to easily format the entered content, such as make it bold, change its size, colors etc. The resulting source code is then submitted as regular text for further processing by your form script.
This script works in IE5+/Mozilla 1.3+/Mozilla Firebird/Firefox 0.6.1+/Netscape 7.1+. In Mozilla, it relies on the Mozilla Rich Text Editing API. Browsers that aren't supported should see just a regular form textarea.
Simply download the zip file rte.zip (right click, select "Save As"), which contains all the necessary files for the script. Included is also "install.htm", our quick guide to adding the script to your form. For easy reference, the installation instructions are shown below as well.
Basic steps to installation
Step 1: Insert the below script into the HEAD section of your page:
**Note: Alternatively, you can insert the below code instead to reference the original, non compressed version of the .js file instead. This file is significantly larger than the compressed version, though the source is human readable:
Step 2: Inside the zip file you downloaded, upload the files:
1) The relevant .js file you have chosen above
Upload the above to your web page directory, in the same directory where your form is in.
Step 3: Inside your form where you wish the rich text editor to appear, add the below code:
As you can see, you can control the initial content and dimensions of the rich text editor. "rtel" is the name of the text editor, which can be arbitrary but should be unique.
Step 4: Finally, just before the form containing the rich text editor is submitted, the script needs to sync the value contained within the editor to ensure it gets properly submitted. To archive this, a special function needs to be attached to the onSubmit event of your form. This is shown below:
<form name="myform" onsubmit="return submitForm();">
Don't be intimated by Step 3. Basically, just add the above script containing function submitForm() to your form, and attach it to the onsubmit event handler inside the form tag.
Adding more than one rich text editor inside the form
You can easily add multiple rich text editors within the same form. Simply repeat Step 3 for each instance of an editor. Then, inside the script of Step 4, change:
to call instead:
And that's it.