title: Getting Current age by user input javascript
body: <p><strong>I want my user when they click on “view age” button to calculate there age from there input</strong>, but i couldn't figure it out. I got the user to view there birth year when they click on the but.</p>
  
  <p>Here is my HTML Code:</p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;form id="birth"&gt;
      &lt;h2&gt;What month were you born?&lt;/h2&gt;&lt;input name="birthMonth" type="text" size="20"&gt;
      &lt;h2&gt;What day was you born?&lt;/h2&gt;&lt;input name="birthday" type="text" size="20"&gt;
      &lt;h2&gt;Your birth year?&lt;/h2&gt; &lt;input name="birthYear" type="text" size="20"&gt;
  
      &lt;/form&gt;
      &lt;button onclick="outputbirth()"&gt;Submit&lt;/button&gt;
      &lt;button onclick="submitBday()"&gt;View Age&lt;/button&gt;
      &lt;p id="output"&gt;&lt;/p&gt;
      &lt;p id="age"&gt;&lt;/p&gt;
      &lt;script type="text/javascript" src="scripts/scripts.js"&gt;&lt;/script&gt;
      &lt;/body&gt;
     &lt;/html&gt;
  </code></pre>
  
  <p>JavaScript Code, function submitBday is the button on the html document:</p>
  
  <pre><code>    function outputbirth() {
      // Getting the form id "birth"
      var x = document.getElementById("birth");
      var text = "";
      // Getting the users input values of Month, Day, Year.
      for (i = 0; i &lt; x.length; i++) {
      text += x.elements[i].value + " ";  
      }
      // This is going to print out the result on output id in the html document 
      document.getElementById("output").innerHTML = text;
      }
  
     function submitBday() {
  
     }
  </code></pre>