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

Buttons submit probleme


hello i finish my code but the " always realod when i click on it without my code works please help me how can i remove the fking realod


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 (7)


Can you share a little more information about your code?

Besides. Try adding e.preventDefault soon after the click



that's the demo2 metrocnic file if you don't have i give you



Not the HTML code btw, just the event handler that you are trying to fix

If it is a form causing the problem, it's most likely that the default action is your pain.

When you submit a form the page reloads, so the server can process the information, if you don't want that behavior you need to add

preventDefault
on the event handler.



on jQuery you can do something like

$("#formId").on("submit", function(e){
e.preventDefault;
---- your code
})



so how i can add it here

<div class="form-group text-center">
<input type="hidden" name="token" value="<?=$_SESSION["token"] ?>"/>
<input type="submit" class="btn btn-primary" value="Mettre &agrave; jour"/>
</div>



why i can't share the code ?



Hi,

If you use the buttons' default behavior it submits the form on click. To avoid this you can use the below code in the bottom of your page, after all core-js scripts includes:


// On document ready()
KTUtil.onDOMContentLoaded(function () {
const myBtn = document.querySelector("#myBtn");
myBtn.addEventListener("click", function (e) {
e.preventDefault();
});
});


Regards.


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  :(