Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7812985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:42:00+00:00 2026-06-02T04:42:00+00:00

Hello how would I create this in Javascript?: You have <strong><span id=commentsCounter>${const[‘COMMENT_MAX_LENGTH’]}</span></strong> characters left.<br/>

  • 0

Hello how would I create this in Javascript?:

  You have <strong><span id="commentsCounter">${const['COMMENT_MAX_LENGTH']}</span></strong> characters left.<br/>

add it above this:

 function editCommentToggle( id )
{
    theRow = document.getElementById("id"+id);
    //user = theRow.cells[0].innerHTML;
    //date = theRow.cells[1].innerHTML;
    com = theRow.cells[2].innerText ;


    idx = 2;
    maxlength = 250;

                // Comment field
        cell = theRow.cells[idx];
        while( cell.childNodes.length > 0 ) cell.removeChild(cell.childNodes[0]);

        //spanTag = document.createElement("span"); 
        //spanTag.innerHTML = "id='commentsCounter'>" + maxlength + "</span>characters left.<br/>" 
        //cell.appendChild(spanTag);
        element = document.createElement("textarea");
        element.id="comments-"+id;
        element.rows="3";
        element.value = com;
        element.style.width = "400px";
        element.maxLength = "250";
        element.onfocus = element.onkeydown = element.onkeyup = function(){return characterCounterEdit(undefined, maxlength, this);}; 
        cell.appendChild(element);

        $(function()
                {
                    setTimeout("syncCommentTableSizes()",0);    <%-- Run after HTC code --%>
                });

    // Actions field
    cell = theRow.cells[++idx];
    while( cell.childNodes.length > 0 ) cell.removeChild(cell.childNodes[0]);

    link = document.createElement("a");
    link.href = 'javascript:saveComment('+id+')';

    element = document.createElement( "img" );
    element.className = "edit"; // check if we need this changed
    element.src="../images/icon_save.gif";
    element.border="0";
    element.alt = "Save";

    link.appendChild( element );

    cell.appendChild(link);
    cell.appendChild( document.createTextNode("  ") );

    link = document.createElement("a");
    link.href = 'javascript:cancelCommentEdit('+id+')';

    element = document.createElement( "img" );
    element.className = "delete"; // check if we need this changed
    element.src="../images/icon_cancel.gif";
    element.border="0";
    element.alt = "Cancel";

    link.appendChild(element);
    cell.appendChild(link);
}

jsp:

<table id="add-comment-table" class="data_table" style="border-top-style: none; margin-top: 0px;">
<td colspan="3">
    You have <strong><span id="commentsCounter">${const['COMMENT_MAX_LENGTH']}</span></strong> characters left.<br/>
    <textarea id="comment" name="comment" rows="3"
        onfocus="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"
        onkeydown="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"
        onkeyup="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"></textarea>
        <a href="javascript:addComment();"><img src="../images/icon_add.gif" border="0" alt="Add"/></a>
</td>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:42:02+00:00Added an answer on June 2, 2026 at 4:42 am

    Output your constant inside the hidden div.

    You can then grab the innerHTML from the html, rather than trying to set it via javascript.

    <div id="maxSize" style="display:none;">${const['COMMENT_MAX_LENGTH']}</div>
    <span id="commentsCounter"></span>
    <div onclick="update()">Click</div>
    
    <script>
        function update()
        {
            var maxLength = parseInt( document.getElementById( "maxSize" ).innerHTML );
            document.getElementById( "commentsCounter" ).innerHTML = maxLength;
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this call my $th = threads->create(\&print, Hello thread World!\n); $th->join(); works fine. But as
I'm trying to create an Hello World JSF application. I have a bean with
Hello good Stack Overflow people, I do have a business problem and would like
Hello javascript experts! I'm a novice here, trying to create a script to add
I'm trying to follow the instructions located at How-To Create a Hello World Snap-in
How should i do to create yyyy/mm/dd directory easy? mysite.com/blog**/2009/01/01/**hello-world.aspx!
I have created a Hello World web part. When I pressed F5 in Visual
I have created button 2 below: <input id=Button1 type=button value=Stop onclick=alert('hello world');/> <input id=Button2
We have tried to create sample webservices helloworld in Java using Jersey and Tomcat
Trying to grasp Prototyping in Javascript. Trying to create my own namespace to extend

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.