Results 1 to 2 of 2

Thread: Character Counter OnLoad

  1. #1
    Join Date
    Feb 2011

    Character Counter OnLoad

    How can I make my character counter display how many characters are left on page load. Right now it only displayed the number of characters left when I user keysup, keysdown or onblurs.

    var companydo = document.getElementById('cscompanydo');

    function validate_companydo_field_length() {
    var len = companydo.value.length;
    var mc = 2000;
    if (len > mc) {
    companydo.value = companydo.value.substring(0,mc);
    len = mc;
    document.getElementById('doremaining').innerHTML = mc - len;

    companydo.onkeyup = validate_companydo_field_length;
    companydo.onkeydown = validate_companydo_field_length;
    companydo.onblur = validate_companydo_field_length;

    <textarea class="medium mediumwidth man" id="cscompanydo" name="companydo" rows="" cols=""><?php echo $answer['companydo']; ?></textarea>
    <div class="f_right mts mrs"><span id="doremaining" class="mrs">2000</span>characters remaining</div>

  2. #2
    Join Date
    Dec 2005
    If you are asking about a progress bar to display how long until load is finished,
    I don't believe JS can acquire this information.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center