Go Back   Dreamweaver Club Forums > Hand Coders Forum > Javascript and JS frameworks
Register FAQ Members List Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Old 07-27-2013, 03:11 PM   #1
Join Date: Jan 2009
Posts: 115
Default Problem with function and the call.

I have a javascript function for a text area counter - works fine.
I tried a new approach to deal with the 'hit enter key' problem so that,
if the enter key is pressed, it deducts 50 from the counter. The need for this is to make sure that the text, plus the enter hits, will keep the text within a defined space on the web page. The deduct 50 character function also works - but only once. Worse still, if you add another character, the character left counter goes back to what the counter was, before 50 character were deducted. I've put the two functions together into another function so they can be called together. I've changed the order of the functions but when I do this, the enter key function does not work at all. I'd like to say that I have some idea what is happening but I don't. Any help would be much appreciated. Here's all the relevant code.

function check_length(writing_details)
maxLen = 700; // max number of characters allowed
if (writing_details.blog_text.value.length >= maxLen) 
// Reached the Maximum length so trim the textarea
writing_details.blog_text.value = writing_details.blog_text.value.substring(0, maxLen);
{ // Maximum length not reached so update the value of my_text counter
writing_details.text_num.value = maxLen - writing_details.blog_text.value.length;}
function break_count(writing_details)
if(event.keyCode == 13)
writing_details.text_num.value = maxLen - writing_details.blog_text.value.length -50;
function textcount()
Here's the call:
HTML Code:
<textarea onKeyDown=textcount(this.form); onKeyPress=textcount(this.form);  name="blog_text" cols=50 rows=10></textarea>
Thanks - songboy
songboy is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 08:35 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com