Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How do use RTE_ConvertTextAreaToRichEdit() function in a customized aspx page in SharePoint 2007?

I tried using a Javascript cleditor together with SPServices but could not get my data inside the rich text box to be store into the multi-lines text field inside a list.

Below are javascript code that I tried for reference only:

CODE A - cleditor

$(document).ready(function() {
    $("#newWordDesc").cleditor();
});

CODE B - SPservices

$(document).ready(function() {

        CreateNewItem($("#newWordDesc").val());

        function CreateNewItem(newWordDesc) {
            $().SPServices({
                operation: "UpdateListItems",
                async: false,
                batchCmd: "New",
                listName: "MyList",
                valuepairs: [["Description", newWordDesc]],
                completefunc: function(xData, Status) {
                   $("#responseStatus").html(Status);
                   $("#responseXML").text(xData.responseXML.xml);

                }
            });
        }

CODE C - HTML TextArea using Javascript

document.write('<textarea id="newWordDesc" wrap="soft"></textarea>');   

Would appreciate if any insight provided.

Update (Based on Amit)

I modify Amit's code as follows and the RTE is now displayed correctly. (However, if one enter data into the RTE field, and submit into a SharePoint List via SPServices, it will not work.)

<script type="text/javascript" language="javascript" src="/_layouts/1033/form.js"></script>
<script type="text/javascript">
    //To determine if browser is IE
$(document).ready(function() {
    if (browseris.ie5up && browseris.win32 && !IsAccessibilityFeatureEnabled())
    {
    RTE_ConvertTextAreaToRichEdit("newWordDesc", true, false, "", "1033", null, null, null, null, null,"FullHtml", "\u002f",null,null,null,null);
    } 
    // else render help link if browser is Non-IE i.e. chrome,firefox etc
    else
    {
    document.write("&nbsp;<br><SPAN class=ms-formdescription><a href='javascript:HelpWindowKey(\"nsfullrichtext\")'>Click for help about adding HTML formatting.</a></SPAN>&nbsp;<br>");
    };
});
</script>
share|improve this question
add comment

1 Answer 1

The function is defined in

/_layouts/1033/form.js

and its signature looks like :

function RTE_ConvertTextAreaToRichEdit(
            strBaseElementID,
            fRestrictedMode,
            fAllowHyperlink,
            strDirection,
            strWebLocale,
            fSimpleTextOnly,
            fEditable,
            fUseDynamicHeightSizing,
            iMaxHeightSize,
            iMinHeightSize,
            strMode,
            urlWebRoot,
            strThemeUrl,
            strBodyClassName,
            fAllowRelativeLinks,
            strBaseUrl,
            fUseDynamicWidthSizing,
            iMaxWidthSize,
            iMinWidthSize,
            fEnforceAccessibilityMode,
            fPreserveScript,
            fHookUpEvents,
            fGenerateToolbar
            )
{....}

In the form,You can use it like :

<script type="text/javascript" language="javascript" src="/_layouts/1033/form.js"></script>
<script>
    //To determine if browser is IE
    if (browseris.ie5up && browseris.win32 && !IsAccessibilityFeatureEnabled())
    {
    RTE_ConvertTextAreaToRichEdit("<<Insert your TextField client Id>>", true, false, "", "1033", null, null, null, null, null,"FullHtml", "\u002f",null,null,null,null);
    } 
    // else render help link if browser is Non-IE i.e. chrome,firefox etc
    else
    {
    document.write("&nbsp;<br><SPAN class=ms-formdescription><a href='javascript:HelpWindowKey(\"nsfullrichtext\")'>Click for help about adding HTML formatting.</a></SPAN>&nbsp;<br>");
    };
</script>
share|improve this answer
    
Strange, it give me a error SCRIPT5007: Unable to get value of the property 'innerText': object is null or undefined point to the file form.js, line 734 character 2. (For your info, my textarea is <textarea id="newWordDesc"></textarea>) –  Larry Morries Nov 3 '11 at 5:05
    
Hi Amit, Thanks, made some modification to your code and now it is working. However, I still could not get the data, which I typed inside this RTE text field into SharePoint 2007 via SPServices. Any Insight? –  Larry Morries Nov 3 '11 at 5:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.