Like this:
<script>
var myArray = ["Atext","Atext","Btext","
alert(mC(myArray));
function mC(theArray){
tempArray = theArray.slice(0,theArray.
tempArray.sort()
mVal = aVal = "";
mCnt = aCnt = 0;
for(i=0;i<tempArray.length
if(aVal!=theArray[i]){
if(aCnt>mCnt){
mCnt = aCnt;
mVal = aVal
}
aVal = theArray[i];
aCnt = 1;
} else {
aCnt++;
}
}
return [mVal, mCnt];
}
</script>
Main Topics
Browse All Topics





by: avnerPosted on 2004-02-03 at 05:21:57ID: 10260707
Here is an example of something like that :
ame); " ");
')"
<html>
<head>
<title>about:blank</title>
<script language="javascript1.2">
<!-- copyright(c) avcoh@yahoo.com
function calculateWords(sName)
{
var oField = document.getElementById(sN
var sString = oField.innerText;
sString =sString.replace(","," ");
sString =sString.replace(/\n|\r/g,
sString =sString.replace(" "," ");
var arr = new Object();
var arrWords = sString.split(" ");
for (var i=0;i<arrWords.length;i++)
{
var sWord = arrWords[i];
if (arr[sWord])
{
arr[sWord]=arr[sWord]+1;
}
else
{
arr[sWord] = 1
}
}
var s = "Total of words in textarea :\n";
for (var i in arr)
{
s+="["+i+"] count is :" + arr[i] + "\n";
}
alert(s);
}
-->
</script>
<style>
</style>
</head>
<body onload="calculateWords('ta
<textarea id="ta" cols="40" rows="30">
this is a list of this is ah words
this is a list of this is ah words
this is a list of this is ah words
this is a list of this is ah words
this is a list of this is ah words
this is a list of this is ah words
this is a list of this is ah words
this is a list of this is ah words</textarea>
</body>
</html>