I have a regular form, when the submit button is clicked I want to hide the submit button, and if any form values change after submitting it'll auto submit again.
I'm using the following code and it works, but each time I update the form data and the form is automatically submit, in the JS console I can see it's being submit many many times, and the number increases each time it auto submits. e.g. first auto submit posted once, second auto submit posted 4 times, third auto submit posted 8 times and then the form starts getting really slow due to this.
jQuery(function($) {
$(document).on("click",'#bookingbutton', function() {
$( "#bookingbutton" ).css( "display", "none" );
$( ".bookroom1" ).addClass( "bookroom1-submit" );
$(".bookroom1-submit").change(function() {
$("#bookingbutton").click();
});
});
});