This project has moved and is read-only. For the latest updates, please go here.

creating Rich Text Editor using new InputFormTextBox() SharePoint 2007

Jul 28, 2015 at 4:50 PM
Edited Jul 28, 2015 at 4:50 PM
I know this probably an easy question to answer, or at least I'm hoping it is. I have a CEWP (Content Editor Web Part) that I'm trying to use custom code to create an input field for access to update a list. I would like the input to be a Rich Text Editor. I've tried writing the following in JavaScript:
$(document).ready(function() {
    user = getUserAccountInfo();
    username = user.PreferredName;

    InputFormTextBox textbox = new InputFormTextBox();
    textbox.ID = "inputFormTextBox1";
    textbox.TextMode = TextBoxTextMode.MultiLine;
    textbox.rows = 6;
    textbox.columns = 75;
I get an error message of needing a semicolon ';' at the line declaring the InputFormTextBox. It looks valid to me. I am then calling the text values from the box, and using SPServices UpdateListItems. I know I saw Marc post about using a RTE elsewhere in his blog posts, but it wasn't too clear how to implement it, so the above solution is what I found that looked like the best solution. But it's giving me the ';' error.
Jul 28, 2015 at 5:04 PM
You're trying to write C#. ;-)

Marked as answer by trout0525 on 7/28/2015 at 12:06 PM
Jul 28, 2015 at 5:50 PM


Is there a JavaScript way?
Jul 28, 2015 at 6:37 PM
There's got to be someway to use:
Jul 28, 2015 at 7:36 PM
No idea about that file. Why not just use an HTML textarea?

Jul 28, 2015 at 8:06 PM
I've already done that, but it ignores line breaks/returns and the rest in multiline input, unless they know some HTML. I was thinking the client might like something a little more fancy, that's all. I'll mark your answer, but if you know a fancier textarea, then by all means, let me know.

Jul 28, 2015 at 9:18 PM

If wanting to stick with a plain textarea, you can add the HTML breaks to it before saving the data to the list.

ex. (warning: untested code)

valueToSave = "
" + $(".your-text-area").val().replace("\r\n", "
").replace("\n", "
") + "

Paul T

Jul 29, 2015 at 1:55 PM
Hello Paul,

Thanks for the idea. I guess I could start writing my own RTE jQuery plugin for SharePoint. ;o)

I'll give the code a go, but I think you would need to implement <br>'s to handle the newlines.

I did try to put some simple <br>s just into the multiline textarea, but they would not post.

Thank You,

Jul 30, 2015 at 9:20 PM
Well, I did get a rich text editor to work with it, to get RTE formatted text. I "unfortunately" had to use CKEditor. I only say "unfortunately" because of a lot of people complaining about it, but I think it works OK. It's just the standard version, so nothing spectacular, but it does handle newlines, bold, italics, ordered and unordered lists, and a few other things too. It's not too bad. It took a little work to get things going with SharePoint 2007 and CKEditor, but wasn't too hard. They supposedly stopped supporting the work with SharePoint, but I think that was only if you wanted it to be a webpart to add to a SharePoint page. If one incorporates the simple textarea transform in a Content Editor Web Part, in custom html code, it works fine. Thanks for all your help.