title: How do I call a create an array to call a function? The called function will display options in a character list in alphabetical order
body: <p>I am working on a homework assignment for a javascript, DHTML class. I need to create a function that creates a selection list. In this function I am trying to create an array "characters" that calls a function uniqueElemText(), which has been provided for me. This function will create the options of the selection list and display them alphabetically. This is my first week working with DHTML and I am lost! Any help would be greatly appreciated!</p>
  
  <p>Here is small clip of the HTML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;!-- 
     New Perspectives on HTML, XHTML and DHTML 4th Edition
     Tutorial 16
     Case Problem 4
  
     The Tempest
     Author: Collin Klopstein
     Date: December 15, 2013  
  
     Filename:         tempest.htm
     Supporting files: bio_out.jpg, globe_out.jpg, plays.css, plays_out.jpg,
                       scene.js, son_out.jpg, strat_out.jpg
  --&gt;
  
  &lt;title&gt;The Tempest, Act V, Scene 1&lt;/title&gt;
  &lt;link href="plays.css" rel="stylesheet" type="text/css" /&gt;
  
  &lt;script type="text/javascript" src="scene.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div id="linklist"&gt;
     &lt;img src="plays_out.jpg"  alt="The Plays" /&gt;
     &lt;img src="son_out.jpg"  alt="The Sonnets" /&gt;
     &lt;img src="bio_out.jpg" alt="Biography" /&gt;
     &lt;img src="globe_out.jpg" alt="The Globe" /&gt;
     &lt;img src="strat_out.jpg" alt="Stratford" /&gt;
  &lt;/div&gt;
  &lt;div id="title"&gt;&lt;img src="tempest.jpg" alt="The Tempest" /&gt;&lt;/div&gt;
  &lt;div id="actList"&gt;&lt;table&gt;&lt;tr&gt;
     &lt;td&gt;ACT I&lt;/td&gt;&lt;td&gt;ACT II&lt;/td&gt;&lt;td&gt;ACT III&lt;/td&gt;
     &lt;td&gt;ACT IV&lt;/td&gt;&lt;td&gt;ACT V&lt;/td&gt;
  &lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
  
  &lt;div id="characterList"&gt;&lt;/div&gt;
  
  
  &lt;div id="sceneIntro"&gt;
  &lt;h2&gt;Lines from Act V, Scene 1&lt;/h2&gt;
  &lt;/div&gt;
  
  &lt;div id="scene"&gt;
  &lt;h3&gt;PROSPERO&lt;/h3&gt;
  &lt;blockquote&gt;&lt;i&gt;Enter PROSPERO in his magic robes, and ARIEL&lt;/i&gt;&lt;/blockquote&gt;
  &lt;blockquote&gt;Now does my project gather to a head:&lt;br /&gt;
  My charms crack not; my spirits obey; and time&lt;br /&gt;
  Goes upright with his carriage. How's the day?
  &lt;/blockquote&gt;
  
  &lt;h3&gt;ARIEL&lt;/h3&gt;
  &lt;blockquote&gt;On the sixth hour; at which time, my lord,&lt;br /&gt;
  You said our work should cease.
  &lt;/blockquote&gt;
  
  &lt;h3&gt;PROSPERO&lt;/h3&gt;
  &lt;blockquote&gt;I did say so,&lt;br /&gt;
  When first I raised the tempest. Say, my spirit,&lt;br/&gt;
  How fares the king and's followers?
  &lt;/blockquote&gt;
  
  &lt;h3&gt;ARIEL&lt;/h3&gt;
  &lt;blockquote&gt;Confined together&lt;br /&gt;
  In the same fashion as you gave in charge,&lt;br /&gt;
  Just as you left them; all prisoners, sir,&lt;br /&gt;
  In the line-grove which weather-fends your cell;&lt;br /&gt;
  They cannot budge till your release. The king,&lt;br /&gt;
  His brother and yours, abide all three distracted&lt;br /&gt;
  And the remainder mourning over them,&lt;br /&gt;
  Brimful of sorrow and dismay; but chiefly&lt;br /&gt;
  Him that you term'd, sir, 'The good old lord Gonzalo;&lt;br /&gt;
  His tears run down his beard, like winter's drops&lt;br /&gt;
  From eaves of reeds. Your charm so strongly works 'em&lt;br /&gt;
  That if you now beheld them, your affections&lt;br /&gt;
  Would become tender.
  &lt;/blockquote&gt;
  
  &lt;h3&gt;PROSPERO&lt;/h3&gt;
  &lt;blockquote&gt;Dost thou think so, spirit?
  &lt;/blockquote&gt;
  
  &lt;h3&gt;ARIEL&lt;/h3&gt;
  &lt;blockquote&gt;Mine would, sir, were I human.
  &lt;/blockquote&gt;
  </code></pre>
  
  <p>and The JavaScript File:</p>
  
  <pre><code>/*
     New Perspectives on HTML, XHTML, and DHTML 4th Edition
     Tutorial 16
     Case Problem 4
  
     Author: Collin Klopstein  
     Date: December 15, 2013    
  
     Filename: scene.js
  
  
     Function List:
     uniqueElemText(elemName)
        Returns the unique content from HTML tags with the
        tag name elemName. The list is sorted in alphabetical
        ordered and returned as an array.
  
  */
  
  
  
  function addEvent(object, evName, fnName, cap) {
     if (object.attachEvent)
         object.attachEvent("on" + evName, fnName);
     else if (object.addEventListener)
         object.addEventListener(evName, fnName, cap);
  }
  
  addEvent(window, "load", characterBox, false);//calls createListBox() when page loads
  
  function uniqueElemText(elemName) {
     elems = document.getElementsByTagName(elemName);
     elemsArray = new Array();
  
     for (var i=0; i&lt;elems.length; i++) elemsArray[i]=elems[i].innerHTML;  
     elemsArray.sort();
     for (i=0; i&lt;elemsArray.length-1; i++) {
        if (elemsArray[i]==elemsArray[i+1]) {
           elemsArray.splice(i+1,1);
           i--;
        }
     }
     return elemsArray;
  }
  
  function characterBox() {
      var boxHead = document.getElementById("characterList");
      boxHead.innerHTML = "&lt;p&gt;Show Only Lines By:&lt;/p&gt;";
      var cList = document.createElement("select");
      boxHead.appendChild(cList);
  
      var characters = new Array(uniqueElemText);
      for (var i = 0; i &lt; characters.length; i++) {
          var options = document.createElement("option");
          cList.appendChild(options);
      }
  }
  </code></pre>