So, I have multiple forms on a page and I am trying to submit them conditionally using the same button, for some reason, I cannot trigger the submit button. Below is my code.
$("#save_contact").on("click", function () {
var contact_type = $("#contact_type").val();
console.log(contact_type);
if (contact_type == 2) {
console.log("here");
$('#supplier_form').submit();
} else if (contact_type == 3) {
} else if (contact_type == 4) {
} else if (contact_type == 5) {
} else if (contact_type == 1) {
}
});
This is my form, at the moment I have only created 1 form.
<div id="supplier_div" class="form_to_save">
<form id="supplier_form" name="supplier_form" action="{{route('save_reception_contacts')}}">
<hr>
<h4>Supplier</h4>
<input type="hidden" name="_token" value="{{csrf_token()}}">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Company</label>
<input type="text" name="company" id="company" />
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Notes</label>
<textarea name="notes" id="notes"></textarea>
</div>
</div>
</div>
<input type="hidden" name="contact_type_hidden">
<input type="hidden" name="user_type_hidden">
</form>
</div>
<div class="col-md-6">
<button type="button">Back</button>
<button type="button" class="save" id="save_contact">Save</button>
</div>