This is the DIV with id=p2_out
- in column 1 place one of the 26 beginning letters: a → z. Assume the following 26 element array is stored in p2:
var alphabet = new Array ("a","b","c", ... ,"z");
- in column 2 place the count of words that begin with the specified letter
- in column 3 place the percent of words that begin with the specified letter
- in column 4 place a bar graph (made from the single pixel file "green1x1.gif' representing the relative percentage of the words from column 3. The maximum bar length is 400 pixels and all bars are 15 pixels tall.
- after the table, report the total number of words
- use one of the 26 letters from the alphabet array for the value in column 1 (a → z)
- retrieve the textarea
- split the above on the "" character into an array named alist
- for each alist element, split the array elements on the "," into an array named temp, store the lengths of temp in an array named listc (the 26 listc values go in column 2)
- sum the values of listc to obtain the total number of words -- call this total: tw
- for each letter, calculate the % of words that begin with that letter, store the result in an array named pcw
(i.e., pcw[i] = listc[i] / tw 100.0 ). These values go in column 3.
- Find the maximum value in pcw -- call this maxp. In column 4, place a graphic image (green1x1.gif) that is 15 pixels tall. Calculate the width of the image for each row by:
width = 400 pcw[i] / maxp.