I am having some trouble using a jquery listener on a submit button to get it to run a function on the form's data. I have this html form:
<div class = "window" id="patientsignup">
<h1>Add New Patient</h1>
<form id = "form1">
<label>First name: </label> <input type="text" name="FirstName" value="First"><br>
<label>Last name: </label><input type="text" name="LastName" value="Last"><br>
<label>Email: </label><input type="text" name="email" value="[email protected]"><br>
<label>Phone Number: </label><input type="text" name="phonenumber" value="Phone Number"><br>
<input type="button" id="patientcreatebutton" name="createbutton" value="Create Patient">
</form>
</div>
And I'm using this jQuery listener in my CSS stylesheet:
$('#patientcreatebutton').click(
createpatient($('#form1'));
);
Here's the javascript function it's calling.
function createpatient(form) {
console.log("Begin creating patient");
var currentUser = Parse.User.current();
var username= form.email.value;
var email= form.email.value;
var doctorIdentifier= currentUser.id;
randkey = makeid();
var password= randkey;
var doctorCode= randkey;
var phoneNumberForPatient= form.phonenumber.value;
var doctorsUserName= currentUser.username;
Parse.Cloud.run("inviteUser", {"email": email, "password": password, "doctorCode": password, "phoneNumberForPatient": phoneNumberForPatient, "doctorUserName": doctorsUserName, "doctorIdentifier": doctorIdentifier}, {
success: function(result) {
console.log("Successfully invited user!");
console.log("Please have your patient log in with the following code: " + doctorCode);
},
error: function(error) {
console.log("There has been an error.");
console.log(error);
}
});
createpatientwindow.style.visibility = "hidden";
$(generatecalorieswindow).addClass("slideLeft");
};
For some reason, I'm not even getting the first console message from the javascript function. Am I hooking up the jQuery listener wrong?