How to Clear Text Area from Javascript

3 posts, 0 answers
  1. mayerh2
    mayerh2 avatar
    14 posts
    Member since:
    Jun 2007

    Posted 28 Jul 2007 Link to this post

    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. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 30 Jul 2007 Link to this post

    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

  3. mayerh2
    mayerh2 avatar
    14 posts
    Member since:
    Jun 2007

    Posted 30 Jul 2007 Link to this post

    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
Back to Top