'undefined function onclick event
I'm trying to create a website that would get the user input, selected options and email those inputted information to the user's email. My problem here is the onClick event doesn't work properly, it does nothing and shows that the function is not defined.
Name:<br><input type="text" id="name" required/> <br/>
<label><br>Example</label>
<br>
<select name="choice">
<option value="" selected>--SELECT--</option>
<option value="choice1">choice1</option>
<option value="choice2">choice2</option>
</select><br>
<button type='submit' onclick='myFunction()'>SUBMIT</button>
The function that would supposedly get the data from user input upon clicking submit.
function myFunction(){
var name = $("#name");
var email = $("#email");
var schedule = $("#schedule");
var time = $("#time");
if(isNotEmpty(name) && isNotEmpty(email) && isNotEmpty(time) && isNotEmpty(schedule)) {
$.ajax({
url: 'send.php',
method: 'POST',
dataType: 'json',
data:{
name: name.val(),
email: email.val(),
schedule: schedule.val(),
time: time.val()
}, success: function(response){
$("#status")[0].reset();
$('.status').text("Kindly check your email for status of Delivery. Thank you!");
}
});
}
}
Solution 1:[1]
Add jquery file to header. I think it's after the jquery code.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Arnab Sikdar |
