title: how can we display html form values as many times as the user insert them by pressing submit button each time?
body: <pre><code>    &lt;form  action=&quot;#&quot;&gt;&lt;/form&gt;
           &lt;label for=&quot;First-name&quot;&gt;First name: &lt;/label&gt;
           &lt;input type=&quot;text&quot; id=&quot;First-name&quot; placeholder=&quot;Please insert fiid.&quot;&gt;&lt;br&gt;
          &lt;label for=&quot;Second-name&quot;&gt;Second name:   &lt;/label&gt;
          &lt;input type=&quot;text&quot;  id=&quot;Second-name&quot;   placeholder=&quot;Please insert second name&quot;&gt; &lt;br&gt;
          &lt;label for=&quot;Passenger-weight&quot;&gt;Passengers weight:   &lt;/label&gt;
          &lt;input type=&quot;number&quot; class=&quot;weight&quot; id =&quot;Passenger-weight&quot;  placeholder=&quot;Please enter passengers weight&quot;&gt;&lt;br&gt;
          &lt;label for=&quot;cargo-weight&quot;&gt;cargo weight:   &lt;/label&gt;
          &lt;input type=&quot;number&quot;  class=&quot;weight&quot; id =&quot;cargo-weight&quot; placeholder=&quot;Please enter cargo weight&quot;&gt;&lt;br&gt;
         &lt;input type=&quot;submit&quot; id =&quot;submit&quot; &gt;&lt;br&gt; 
        &lt;/form&gt;
        &lt;p id=&quot;sum&quot;&gt;&lt;/p&gt;
        &lt;div id=&quot;sumoftotal&quot;&gt;&lt;/div&gt;
        
        
  &lt;body&gt;
   &lt;script language=&quot;JavaScript&quot;&gt;
  document.getElementById(&quot;submit&quot;).onclick=function (){
    let firstName = document.getElementById(&quot;First-name&quot;).value;
  let lastName= document.getElementById(&quot;Second-name&quot;).value;
   let num1 = document.getElementById(&quot;Passenger-weight&quot;).value;
   let num2 = document.getElementById(&quot;cargo-weight&quot;).value;
  let total =parseInt(num1) + parseInt(num2); 
  document.getElementById(&quot;sum&quot;).innerHTML=(`${firstName} ${lastName} ${total }`)
  }
    &lt;/script&gt; 
  &lt;/body&gt;
  </code></pre>
  <p>my problem can be numbered:
  number 1: when I press the submit button, input values show up, BUT when I want to insert a different data, the previous one disappear. I studied about it, because whatever comes in the function scope become local we cannot apply it outside, BUT I don't know how to change it.
  number 2: I want to have the sum of total weights I insert at the end of my list, I know we can do this by loop, BUT I need something simpler and more preliminary because I am a novice and it would be a big jump for the time being.
  all in all, I would be happy if anyone could help me.</p>