Write a script based on the program that inputs several lines of text and uses String method indexOf to determine the total number of occurrences of each letter of the alphabet in the text. Uppercase and lowercase letters should be counted together. Store the totals for each letter in an array, and print the values in tabular format in an XHTML textarea after the totals have been determined.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>CountThem</title>
<script type="text/javascript">
<!--
function search1()
{
var str1 = document.getElementById("string1").value;
var str2 = new Array ("a", "b", "c" , "d", "e", "f", "g" , "h" , "i", "j", "k" , "l" , "m", "n" , "o" , "p" , "q", "r", "s", "t" , "u", "v", "w" , "x", "y" , "z");
var str11=str1.toLowerCase();
var len=str11.length;
document.getElementById("ans").value="" ;
for(i=0;i<26;i++)
{
var count=0;
var search=str11.indexOf(str2[i]);
for(j=0;j<len;j++)
{
if(parseInt(search)!= -1)
{
count++;
var search=str11.indexOf(str2[i],parseInt(search)+1);
}
}
if(count!=0)
{
document.getElementById("ans").value= document.getElementById("ans").value + "\n" + str2[i] + " Occurs " + count + " times";
}
}
}
// -->
</script>
</head>
<body>
<table style="width: 100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">&nbsp;</td>
<h1>CountThem</h1>
<hr />

<p>Press F5 or Refresh to load script again. This is a program to determine the total number of occurrences of each letter of the alphabet in the text .</p>
<form name = "search" action = "">
<table border = "1">
<caption>Search</caption>
<tr><td>Enter any String</td>
<td><input name = "string1" type = "text" />
</td></tr>
<tr><td>Search Result</td>
<td><textarea name="ans" rows="26" cols="20">
</textarea>
</td></tr>
<tr><td><input type = "button" value = "CountThem"
onclick = "search1()" /></td></tr>
</table>
</form>
</td>
</tr>
</table>

</body>
</html>