Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

Submit form in stepper not working


I have the following code from create-app.js. How to modify the code so that the form will be submitted to server side upon clicking the submit button.


formSubmitButton.addEventListener("click", function (e) {
// Validate form before change stepper step
var validator = validations[2]; // get validator for last form

validator.validate().then(function (status) {
formSubmitButton.disabled = false;

if (status == "Valid") {

// Prevent default button action
e.preventDefault();

// Disable button to avoid multiple click
formSubmitButton.disabled = true;

// Show loading indication
formSubmitButton.setAttribute("data-kt-indicator", "on");

// Simulate form submission
setTimeout(function() {
// Hide loading indication
formSubmitButton.removeAttribute("data-kt-indicator");

// Enable button
formSubmitButton.disabled = false;
$( "#create_new_bo" ).submit();
}, 2000);



} else {
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-light"
}
}).then(function () {
KTUtil.scrollTop();
});
}
});
});


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (4)


I tried $( "#create_new_bo" ).submit(); but it does not work



Hi,

You should use the form object and call it's submit method form.submit() as shown below:

Replace the below demo timeout code to similate the form processing:

// Simulate form submission
setTimeout(function() {
// Hide loading indication
formSubmitButton.removeAttribute("data-kt-indicator");

// Enable button
formSubmitButton.disabled = false;

stepperObj.goNext();
}, 2000);


With the below actual code:

// Hide loading indication
formSubmitButton.removeAttribute("data-kt-indicator");

// Enable button
formSubmitButton.disabled = false;

stepperObj.goNext();

form.submit();


Regards.



Thank you Sean!. You saved my life. All good now.



Always glad to help you happy


Your Support Matters!

We will highly appreciate your Metronic Review on Themeforest.
Please go to Themeforest Downloads page, select Metronic & leave your feedback.
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(