title: Capture form data in an Object on submit
body: <p>I have a problem. I don't have much experience with object oriented javascript.
  I would like my form to submit details such as first and second name to an object I have created</p>
  
  <p><strong>This is my object:</strong></p>
  
  <pre><code>      function Person(fname,sname){
          this.fname=fname;
          this.sname=sname;   
  
          this.confirm = function(){
              alert('Thank you '+this.fname +'&lt;br&gt;'+ this.sname + ' Your email has been recieved');
          }
  
      function submit(){
          person1= new Person(document.getElementById('fname').value, document.getElementById('sname').value);
  person1.confirm();
      }
  </code></pre>
  
  <p>and my form:</p>
  
  <pre><code>&lt;input type="text" id="fname" value="First Name"/&gt;&lt;/br&gt;
  &lt;input type="text" id="sname" value="Surname"/&gt;&lt;/br&gt;
  &lt;input type="text" value="Email Address"/&gt;&lt;/br&gt;
  &lt;input type="Submit" value="Submit" onSubmit="submit()"/&gt;
  </code></pre>
  
  <p>Please if someone can help me to get this to work I would appreciate it. Thanks.</p>