Chezshire Posted July 8, 2008 Share Posted July 8, 2008 I'm was hoping that i could apply the following script to two places and that they would both count down individually. when i apply it to two boxes (both set up as you see below with the script above preceeding the textarea it is to apply to), neither works. But if i get rid of the script from one then the other will work. What do i need to do get these to behave the way i want to so i have a model i can use to apply as many word counters as i want on a page or pages? <SCRIPT language="javascript"> // Live Word Count Script - added May 2nd --> function wordCounter(field, countfield, maxlimit) { wordcounter=0; for (x=0;x<field.value.length;x++) { if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ") {wordcounter++} // Counts the spaces while ignoring double spaces, usually one in between each word. if (wordcounter > 9999) {field.value = field.value.substring(0, x);} else {countfield.value = maxlimit - wordcounter;} } } function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) {field.value = field.value.substring(0, maxlimit);} else {countfield.value = maxlimit - field.value.length;} } // End --> </script> <tr> <td width="30%" align="right" valign="top"><p>HISTORY:<br><span class="fineprint">Please describe the character's full history here. The text should be written in the stanard 'third-person' narrative, and be a minimum of 500 words.</p> </td> <td valign="top"><textarea name=HISTORY cols='55' rows='35' wrap='virtual' onKeyDown="wordCounter(this.form.Q3367,this.form.remLen,500);" onKeyUp="wordCounter(this.form.HISTORY,this.form.remLen,500);"><?php echo $record["history"]; ?></textarea><br><span class='fineprint'>Words remaining: <input type='text' readonly name='remLen' size='5' value='500'></span><br><INPUT TYPE="reset" VALUE="Reset" id=reset1 name=reset1></td></tr></textarea></td></tr> </table> Also why did this forum make me make a poll so i could post? Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 8, 2008 Share Posted July 8, 2008 You probably accidentally click "make new poll" Quote Link to comment Share on other sites More sharing options...
Chezshire Posted July 8, 2008 Author Share Posted July 8, 2008 Yes that is what I did. Do you have any idea as to the cause of my problem? Why the word counter won't work if applied twice on the same page? Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 8, 2008 Share Posted July 8, 2008 I'm working on it right now. I'm not experienced with Q3367 with javascript(I have no clue what it does, and every google search for that number shows the exact code you've posted), so I'm testing things... I'll post if I get something Quote Link to comment Share on other sites More sharing options...
Chezshire Posted July 8, 2008 Author Share Posted July 8, 2008 Thanks -- I'm researching and testing it too And i don't get why it doesn't work: In my edit page, i have the JS, followed by the text area i want to count text on, and then i do the same thing again which i plug the JS in again and then the textarea i want to count text in. I thought that would work but it doesn't and i don't know why and it makes me sad - thanks for any help you can give. -Chez Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.