I have a form. Once the user enters the details and presses the submit button it shows another div and hides the original. In the other div the button is supposed to actually submit the form instead of the one in the form itself. I'm using preventDefault() to do this, but the submission is not working.
$('#tripinfo').submit(function(e) {
if (e.originalEvent && e.originalEvent.isTrusted)
e.preventDefault();
$("#choosing").slideUp();
$("#confirmation").slideDown();
});
$("#ok").click(function() {
$('#tripinfo').submit();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form action="rideHandler.php" method="POST" id="tripinfo">
//form inputs
<button type="submit" class="subBtn" name="offer"> Finish up</button>
</form>
<div class="confirmation" id="confirmation" style="display:none" ;>
//not important stuff
<button id="ok" type="submit" class="subBtn" name="ok">Offer my ride</button>
</div>
I don't think you need to see the PHP because it works without preventing the original button from submitting, but I'm using
if (isset($_POST['ok']))
Should it be if (isset($_POST['offer']))? Even though I tried it and nothing changed, what is the issue?