Javascript setHTML() won't set editor to a null value

  •  06-06-2007, 1:02 PM

    Javascript setHTML() won't set editor to a null value

    I have an editor on a form created server side with the following code:
     
          CommentEditor.ID = "TaskCodeComment"
          CommentEditor.Text = sCurrentComment
          CommentEditor.FilesPath = "ce/CuteEditor_Files"
          CommentEditor.EditorBodyStyle = "font:normal 12px arial;"
          CommentEditor.EditorWysiwygModeCss = "asp.css"
          CommentEditor.ConfigurationPath = "ce/CuteEditor_Files/Configuration/dossier.config"
          CommentEditor.UseHTMLEntities = false
          CommentEditor.BreakElement = "Br"
          CommentEditor.ShowBottomBar = false
          CommentEditor.Width = "100%"
          CommentEditor.CustomAddons = "<img title=""Save Comments"" class=""CuteEditorButton"" onmouseover=""CuteEditor_ButtonCommandOver(this)"" onmouseout=""CuteEditor_ButtonCommandOut(this)"" onmousedown=""CuteEditor_ButtonCommandDown(this)"" onmouseup=""CuteEditor_ButtonCommandUp(this)"" ondragstart=""CuteEditor_CancelEvent()"" Command=""SaveComment"" src=""ce/CuteEditor_Files/images/save.gif"" />"
          CommentEditor.Draw()
    Through Javascript, it displays text retrieved from a database when a drop down is changed.  Depending on the item selected in the drop down, an item may or may not have text.  If it does, using the javascript API, I use editor.setHTML(sText) to update the editor window with the text.
     
    This works fine.  It's when there isn't any text that I have the problem.  editor.setHTML('') doesn't work.  The text in the editor remains.  I created 2 test buttons to test this functionality
     
    This line works
    <input type="button" value="Click" onclick="document.getElementById('CE_TaskCodeComment_ID').setHTML('DAN');alert(document.getElementById('CE_TaskCodeComment_ID').getHTML())"
    />
    It sets the content of the editor to DAN.  The alert box displays DAN as well.
     
    This line does not work.
    <input type="button" value="Click" onclick="document.getElementById('CE_TaskCodeComment_ID').setHTML('');alert(document.getElementById('CE_TaskCodeComment_ID').getHTML())" />
     
    The previous text that was in the editor (in this case DAN) remains in the box and the alert displays DAN as well.
     
    I've tried various renditions of trying to do this but none work.  This includes trying the above from within a called javascript function and setting a variable to the editor object and calling editor.setHTML(sSomeText).  Nothing works.
     
    Anyone have any idea?
View Complete Thread