I am facing a challenge as I do not have much experience with object-oriented JavaScript. My goal is to have a form submit details such as the first and last name to an object that I've created.
Here is the object I have:
function Person(firstName, lastName){
this.firstName = firstName;
this.lastName = lastName;
this.confirm = function(){
alert('Thank you '+ this.firstName +'<br>'+ this.lastName + ' Your email has been received');
}
}
function submit(){
person1 = new Person(document.getElementById('firstName').value, document.getElementById('lastName').value);
person1.confirm();
}
And here is my form:
<input type="text" id="firstName" value="First Name"/></br>
<input type="text" id="lastName" value="Last Name"/></br>
<input type="text" value="Email Address"/></br>
<input type="Submit" value="Submit" onSubmit="submit()"/>
If someone could assist me in getting this to work properly, it would be greatly appreciated. Thank you.