Using Javascript and jquery I want to write code does the following: When the user fills out a html form, a new object is automatically created with properties provided by the user. I have a constructor
function object (prop1, prop2, prop3) {
this.prop1 = prop1;
this.prop2 = prop2;
this.prop3 = prop3;
}
I am obtaining user input with jquery val() like this:
object.prop1 = $('input[name = "input1"]').val();
object.prop2 = $('input[name = "input2"]').val();
object.prop2 = $('input[name = "input3"]').val();
What I misst is I think somewhere between the contructor and the user input. If I want to create a new object I write
apple = new object (prop1, prop2, prop3);
I want the code to automatically create a new object every time a user fills out the form. I tried to do it with a for loop but I did not succeed. I am a total beginner so I guess I am missing something very basic here. Any advice please?
apple = {prop1: prop1, prop2: prop2, prop3: prop3};?