title: javascript function not being called/not working from html form
body: <p>This is my whole html page</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt; text conversion&lt;/title&gt;
  &lt;script type="text/javascript"&gt;
  function testResults(form)
  {
  
  var str = form.stringn.value;
  
  str.split(" ");
  document.write("testing1");
  var length = str.length;
  var newn = "";
  
  for(var i = 0; i&lt;length; i++)
  {
      if(str[i].charAt(str[i].length - 1) != ".")
      {
          str[i] = str[i] + ".";
      }
      str[i] = str[i] + " ";
      str[i].charAt(0) = str[i].charAt(0).toUpperCase();
      newn = newn + str[i];
  
  }
  document.write(newn);
  document.write("testing");
  }
  
  
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form name="stringform" action="" method="get"&gt;
  Text: &lt;input type="text" name="stringn"&gt;&lt;br&gt;
  &lt;input type="button" name="Convert" Value="convert" onClick="testResults(this.form)"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  
  
  &lt;/html&gt;
  </code></pre>
  
  <p>The html is being displayed correctly, but the button does not produce any action. I even tried document.write("testing") below the loop in the javascript, which had no effect, which makes me think the function is not being called at all. The idea of the function is to format the input string to capitalise the first letter of each word, and put a period after each word. </p>
  
  <p>This is my first time trying to use javascript, so possibly I'm doing something wrong that should be obvious? </p>
  
  <p>final solution:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt; text conversion&lt;/title&gt;
  &lt;script type="text/javascript"&gt;
  function testResults(form)
  {
  
  var str = form.stringn.value;
  
  var strn = str.split(" ");
  
  var length = strn.length;
  var newn = "";
  
  for(var i = 0; i&lt;length; i++)
  {
  
      if(strn[i].charAt(strn[i].length - 1) != ".")
      {
          strn[i] = strn[i] + ".";
      }
      strn[i] = strn[i].charAt(0).toUpperCase() + strn[i].slice(1);
  
      strn[i] = strn[i] + " ";
      newn = newn + strn[i];
  
  
  }
  document.write(newn);
  
  }
  
  
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form name="stringform" action="" method="get"&gt;
  Text: &lt;input type="text" name="stringn"&gt;&lt;br&gt;
  &lt;input type="button" name="Convert" Value="convert" onClick="testResults(this.form)"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  
  
  &lt;/html&gt;
  </code></pre>