heres my script

function count_chars(tarea)
	{
	if ( document.getElementById("checkchars").checked ) 
		{
			x=document.myform.tarea.value;
			document.myform.charcount.value=x.length;
		}
    else 
		{  
            var x ;
            x = document.myform.tarea.value.replace(/\n/g,'');
            var y  = x.split(' ');
            document.myform.charcount.value = x.length - ( y.length  - 1) ; 
        }
	}

function count_words(tarea)
   {
	var y=tarea.value;
	var r = 0;
	a=y.replace(/\s/g,' ');
	a=a.split(' ');
	for (z=0; z<a.length; z++) 
		{
			if (a[z].length > 0) r++;
		}
   document.myform.wordcount.value = r;
   }

function count_lines(tarea)
	{
	if(tarea.value == "")
		{
		document.myform.linecount.value = 0;
		}
	else
		{
		var text = tarea.value.replace(/\s+$/g,"");
		var x = text.split("\n");
		document.myform.linecount.value = x.length;
		}
	}
function count_spaces(tarea)
	{
    var x ;
    x = document.myform.tarea.value.replace(/\n/g,'');
    var y  = x.split(' ');
    document.myform.spacecount.value =  (y.length  - 1) ; 
	}
function count_digits(tarea)
	{
	var x = tarea.value; 
	var chr = "";
	var ndigits = 0;
	for (position = 0; position < x.length; position++)
		{
		chr = x.charAt(position);
		if (chr >= "0" && chr <= "9") 
			{
			ndigits++;
			}
		}
	document.myform.digitcount.value = ndigits;
	}
function all(tarea)
	{
	count_chars(tarea);
	count_words(tarea);
	count_spaces(tarea);
	count_lines(tarea);
	count_digits(tarea);
	}
function txtClear(tarea)
	{
	tarea.value=""; 
	tarea.focus();
	document.myform.charcount.value = "";
	document.myform.wordcount.value = "";
	document.myform.linecount.value = "";
	}

HTML

<input type="button" align="left" value="Count"
		  onClick="all(document.myform.tarea)" />

The Function All() dont seem to work

rename for
function all
to
function allnew (i think all is inbuilt keyword)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.