This is a migrated thread and some comments may be shown as answers.

How to Clear Text Area from Javascript

2 Answers 225 Views
WebParts for SharePoint
This is a migrated thread and some comments may be shown as answers.
mayerh2
Top achievements
Rank 1
mayerh2 asked on 28 Jul 2007, 06:08 AM
I need to reset (clear) the text area of Rad Editor (contained in a MOSS template) from Javascript.

<radE:RadHtmlField ID="RadEditorText2E" FieldName="AMCText2XHTML" runat="server" AllowFonts="False" AllowHtmlSourceEditing="True" DisplayHeight="400px" DisplayWidth="430px" DisableCustomStyles="True"/>

I have found this info in a thread:
<rade:radEditor id= "RadEditor1" runat= "server"></rade:radEditor>
    var editor = <%=RadEditor1.ClientID %>; //get a reference 
     editor.SetHtml("");

But this does not work with MOSS - how could it -
<%=RadEditorText2E.ClientID %> returns a string. How can I get the necessary reference. And what kind of object does the reference point to. I can get a reference to the text area HTML element: <textarea style='display:none' id='RadEContentHiddenTextareactl00_PlaceHolderMain_TextPanel2E_RadEditorText2E_ctl00' .....
But clearing the value of this text area does not work.

Thank you in advance for help.

Regards,

Hugo

2 Answers, 1 is accepted

Sort by
0
Lini
Telerik team
answered on 30 Jul 2007, 06:36 AM
Hi Hugo,

You can use an alternative method to get a reference to the editor client object. Each editor object on the page is included in a JavaScript array, called RadEditorGlobalArray. Here is some sample code to help you:

<script type="text/javascript">  
function test()  
{  
    if (typeof(RadEditorGlobalArray)!="undefined")  
    {  
        for(i=0;i<RadEditorGlobalArray.length;i++)  
        {  
            var editor = RadEditorGlobalArray[i];  
            //alert(editor);  
            editor.SetHtml("");  
        }  
    }  
}  
</script> 

The editor.SetHtml("") function will clear the editor contents

Best wishes,
Lini
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
mayerh2
Top achievements
Rank 1
answered on 30 Jul 2007, 10:04 PM
Hi Lini,
this was exactly the information I was searching for. Since I have the ClientID of the RadEditor, using editor.Id I can locate the editor instance I want to clear.

Thank you so much for this prompt help.

Regards,

Hugo
Tags
WebParts for SharePoint
Asked by
mayerh2
Top achievements
Rank 1
Answers by
Lini
Telerik team
mayerh2
Top achievements
Rank 1
Share this question
or