Jump to content


This topic is now archived and is closed to further replies.


Can't get textarea character counter to work with other javascripts!

Recommended Posts


I am writing a form but am having difficulty getting two javascripts to run together. I can get both of them working on their own but not together (I'm using the latest Firefox browser)! The javascripts are:

A wysiwyg text editor
A textarea character counter

You can see my form here:

I tried a second method also (it also doesn't work) which you can see here:

Can anyone tell me why the textarea character counter does not work?

Many thanks

p.s. I posted on a different forum and only got 1 post which said the counter worked but not the WYSIWYG editor (on Safari browser).

Share this post

Link to post
Share on other sites
Could you post just the revelant code snippets?

Share this post

Link to post
Share on other sites
I think it is easiest if i just give you the whole script. May i draw your attention to the 'Label Description:' which is where i am attempting to get both the WYSIWYG editor and character counter to work.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<TITLE> Add Blog </TITLE>

< script type="text/javascript" >

* Drop Down Date select script- by JavaScriptKit.com
* This notice MUST stay intact for use
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and more

var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];

function populatedropdown(dayfield, monthfield, yearfield){
var today=new Date()
var dayfield=document.getElementById(dayfield)
var monthfield=document.getElementById(monthfield)
var yearfield=document.getElementById(yearfield)
for (var i=0; i<31; i++)
dayfield.options[i]=new Option(i+1, i+1)
dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
for (var m=0; m<12; m++)
monthfield.options[m]=new Option(monthtext[m], monthtext[m])
monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
var thisyear=today.getFullYear()
for (var y=0; y<20; y++){
yearfield.options[y]=new Option(thisyear, thisyear)
yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
</ script >
< SCRIPT LANGUAGE="JavaScript" >

<!-- Begin
  var submitcount=0;
  function checkSubmit() {

      if (submitcount == 0)

function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit)
      {field.value = field.value.substring(0, maxlimit);}
      {countfield.value = maxlimit - field.value.length;}
//  End -->
</ script >

< script language="JavaScript" type="text/javascript" src="wysiwyg.js" ></ script >


So you've just visited some place new and exciting...well blog those experiences right here. <br>
The 'Travel Blog' & 'Associated Link' are not mandatory.<br><br>

< script language="JavaScript" type="text/javascript" src="wysiwyg.js" ></ script >

<form name=add_blog action="insert.php" method="post">

Title: <br><input type="text" size="79" id="title" method="post" name="title"></input> <br><br>

Date: <br>
<select id="daydropdown"></select>

<select id="monthdropdown"></select>
<select id="yeardropdown"></select> <br><br>

Label Description: <br><textarea rows="5" cols="100" id="description" name="description" onKeyDown="textCounter(this.form.description,this.form.remLentext,255);" onKeyUp="textCounter(this.form.description,this.form.remLentext,255);"></textarea>
< script language="JavaScript1.2">generate_wysiwyg('description');</ script >
<br>Characters remaining: <input type=box readonly name=remLentext size=3 value=255 />

Travel Blog: <br><textarea rows="25" cols="100" id="blog" name="blog"></textarea>
< script language="JavaScript1.2" >generate_wysiwyg('blog');</ script >


Latitude: <br><input type="text" size="7" id="lat" name="lat"></input> <br><br>

Longitude: <br><input type="text" size="7" id="lon" name="lon"></input> <br><br>

Associated Link: <br><textarea rows="10" cols="100" id="link" name="link"></textarea>
< script language="JavaScript1.2" >generate_wysiwyg('link');</ script >

Marker: <br><input type="text" size="10" id="marker" name="marker"></input> <br><br>

<INPUT TYPE="button" VALUE="Submit" onclick='' name="submit" />

< script type="text/javascript" >
//populatedropdown(id_of_day_select, id_of_month_select, id_of_year_select)
populatedropdown("daydropdown", "monthdropdown", "yeardropdown")
</ script >


Many thanks - i hope you can see a solution!

Share this post

Link to post
Share on other sites
Maybe it's easier for you, but I don't have time to wade though all that code.

Are you sure that your textCounter function is being called?

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.