title: Making a sum with 4 values and a button
body: <p>I'm trying to make a sum of 4 entries in 4 text type and everything seems fine except that when I click the button, it won't set the sum. Like if I enter 1 in each text input, the text input for the sum should show 4. Thanks!</p>
  
  <p>here's my Javascript code :</p>
  
  <pre><code>(function(){
  var oForm = document.forms;
  
  oForm[2].querySelector("input[type='button']").
                                          addEventListener("click",
                                              sommeValeur,
                                              false);
  }) ()
  
  function sommeValeur() {
  
    var aTxt = document.forms[0].tEx1;
    var total = document.forms[0].tEx2;
  var txt1  = aTxt[0].value;
  var txt2  = aTxt[1].value;
  var txt3  = aTxt[2].value;
  var txt4  = aTxt[3].value;
  
  total = parseInt(txt1) + parseInt(txt2) + parseInt(txt3) + parseInt(txt4) ;
  
  return true;
  }
  </code></pre>
  
  <p>Here's my html code : </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Document&lt;/title&gt;
  &lt;link rel="stylesheet" href="css/form.css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;section&gt;
              &lt;form name="frm1"&gt;
                  &lt;label&gt; Valeur 1:
                      &lt;input type="text" name="tEx1" /&gt;
                  &lt;/label&gt;
                  &lt;label&gt; Valeur 2:
                      &lt;input type="text" name="tEx1" /&gt;
                  &lt;/label&gt;
                  &lt;label&gt; Valeur 3:
                      &lt;input type="text" name="tEx1" /&gt;
                  &lt;/label&gt;
                  &lt;label&gt; Valeur 4:
                      &lt;input type="text" name="tEx1" /&gt;
                  &lt;/label&gt;
              &lt;/form&gt;
          &lt;/section&gt;
  
          &lt;section&gt;
                  &lt;form name="frm2"&gt;
                  &lt;label&gt; Somme:
                      &lt;input type="text" name="tEx2" /&gt;
                  &lt;/label&gt;
                  &lt;/form&gt;
          &lt;/section&gt;
  
          &lt;section&gt;
                  &lt;form name="frm3"&gt;
                  &lt;label&gt;
                      &lt;input type="button" 
                      value="bouton" 
                      name="btn1" /&gt;&lt;/br&gt;
                  &lt;/label&gt;
                  &lt;/form&gt;
          &lt;/section&gt;
  &lt;/body&gt;
  &lt;script src="js/exercise4.js"&gt;&lt;/script&gt; 
  &lt;/html&gt;
  </code></pre>