[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1073
  • Last Modified:

Tinymce count characters...

Hello.
I m trying to instal tinymce in my pages.
Everything working OK so far but i need a function to count down the remaining characters that the user allowed to type in the tinymce editor.
In ther forum iv found this that working fine with mozilla FF but is not in IE.

var myTimer = "";
var myLength = 1000; // max. number of chars allowed
var myContent = "";

function checkChars(){
  if (tinyMCE.getContent('elm1').length > myLength){
    tinyMCE.setContent(myContent);
  } else {
    myContent = tinyMCE.getContent('elm1');
    window.document.Form1.showcharsleft.value=myLength-tinyMCE.getContent('elm1').length;
  }
  myTimer = setTimeout("checkChars()",500); // call function again with a timeout of 500ms
}

where elm1 my editors id and showcharsleft the id of the area displaying the characters left.

<textarea id="elm1" name="elm1" rows="10" cols="60"></textarea>
<input id="showcharsleft" name="showcharsleft" type="text" value="1000" size="5" maxlength="4"> Chars left

There is any way to make it work with IE too ????
0
NTGrE
Asked:
NTGrE
  • 2
  • 2
1 Solution
 
basicinstinctCommented:
Personally I have no idea about tinyMCE.  I played around with your code and took out all of that tinyMCE stuff, so I don't know if it's any good to you, but what the heck:

<html>
<head>
<title>Test</title>
      <script language="JavaScript">
            var myLength = 1000; // max. number of chars allowed
            var myContent = "";
            
            function checkChars()
            {
              var txt = document.Form1.elm1.value;
              if (txt.length > myLength)
              {
                document.Form1.elm1.value = myContent;
              }
              else
              {
                   myContent = txt;
                document.Form1.showcharsleft.value = myLength - myContent.length;
              }
            }
      </script>
</head>
<body>
<form name="Form1">
  <textarea id="elm1" name="elm1" rows="10" cols="60" onKeyUp="checkChars();"></textarea>
  <input id="showcharsleft" name="showcharsleft" type="text" value="1000" size="5" maxlength="4"> Chars left
</form>
</body>
</html>    
0
 
NTGrEAuthor Commented:
Thnx basicinstinct or your reply....

BUT...

Is not working.
0
 
basicinstinctCommented:
come come now - surely you jest!
it works fine on IE and Firefox for me - check it out here: http://malydog.homeip.net/ee/Q_21866440.html
does that work for you...?

BTW - I have something similar going here: http://malydog.homeip.net/jsp/NewGBEntry.jsp 
But the code is quite different.
0
 
NTGrEAuthor Commented:
I know that is working in IE and FF.
Is not working when tinymce is enabled.
:((

I v found several functions that doing the same thing...but seems that tinymce need something special.

Anyway thank you very much for your Help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now