in Education by
I just added a textarea to my page which is an "include" to another page...I have some script that does a counter in the textarea...heres the code for that: function characterCounter(spanId, maxLen, inputElement) { if (spanId) { // Update the counter the user sees. var whatIsLeft = maxLen - inputElement.value.length; if ( whatIsLeft < 0 ) whatIsLeft = 0; spanId.innerText = whatIsLeft; } // Restrict user from entering more than the maxlen. if ( inputElement.value.length > maxLen ) { inputElement.value = inputElement.value.substring( 0, maxLen ); } } The I get a javascript error here as soon as I type....any suggestions Add You have ${const['COMMENT_MAX_LENGTH'] - fn:length(commentForm.comment)} characters left.
Thanx these two lines say: "object expected"...in the debugger onkeydown="characterCounter(commentsCounter,250, this)" onkeyup="characterCounter(commentsCounter,250, this)"> JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Replace: onkeydown="characterCounter(commentsCounter,250, this)" onkeyup="characterCounter(commentsCounter,250, this)"> With onkeydown="characterCounter('commentsCounter',250, this)" onkeyup="characterCounter('commentsCounter',250, this)"> And function characterCounter(spanId, maxLen, inputElement) { if (spanId) With function characterCounter(id, maxLen, inputElement) { spanId = document.getElementById(id); if (spanId) Your code as it stands, expects commentsCounter to be a globally accessible variable. In order to access the element with id commentsCounter, you must use document.getElementById

Related questions

0 votes
    I just added a textarea to my page which is an "include" to another page...I have some script ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I have a CKEditor in my page. Like this Facelet Title function comeBack(){ document.getElementById(editorValue ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I have a CKEditor in my page. Like this Facelet Title function comeBack(){ document.getElementById(editorValue ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I Know I can do this with static HTML, but I want to create dynamically, and I am struggling a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 12, 2022 in Education by JackTerrance
0 votes
    I Know I can do this with static HTML, but I want to create dynamically, and I am struggling a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    I have the access to this DOM node in temp1.$el. And here is the content which the above variable ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    I have the access to this DOM node in temp1.$el. And here is the content which the above variable ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I have the access to this DOM node in temp1.$el. And here is the content which the above variable ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I am developing a web page code, which fetches dynamically the content from the server and then places this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
0 votes
    I'm sending HTML trough POST and the '&'s are messing it up, how can I avoid it? Tried ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I am trying to create an app using AngularJS that takes a user's location (from their mobile) and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    I am trying to create an app using AngularJS that takes a user's location (from their mobile) and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 12, 2022 in Education by JackTerrance
0 votes
    [reposting deleted question with more detail] I've searched for an answer to this but not found a reference ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    [reposting deleted question with more detail] I've searched for an answer to this but not found a reference ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
...