-- This is not a duplicate question. Please read the question thoroughly --
I am trying to post a form dynamically (dynamic form action) using jQuery which works well in almost all browsers, but doesn't work in Microsoft Internet Explorer and Edge.
- It just refreshes the page rather than posting when using the above browsers.
- Don't see any JavaScript errors in browser console.
Here is a code:
<form id="booking" name="booking" method="post">
<!-- form data goes here -->
</form>
<script>
var $j = jQuery.noConflict();
$j(document).ready(function() {
$j('#booking').submit(function() {
var theForm = document.getElementById("booking");
var x = document.forms["booking"]["chargetotal"].value;
var payment_method = document.forms["booking"]["payment"].value;
if (payment_method == "Card") {
$j(this).attr("action", "<?php bloginfo('url'); ?>/confirmation");
}
if (payment_method == "Transfer") {
$j(this).attr("action", "<?php bloginfo('url'); ?>/confirmation-bacs");
}
if (x == '0.00' || x == '0') {
$j(this).attr("action", "<?php bloginfo('url'); ?>/confirmation-2");
}
});
});
</script>
Any help will be highly appreciated.