Skip to content

Instantly share code, notes, and snippets.

@phenix-factory
Last active December 15, 2015 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phenix-factory/5187519 to your computer and use it in GitHub Desktop.
Save phenix-factory/5187519 to your computer and use it in GitHub Desktop.
jQuery: soumettre automatiquement un formulaire.
/**
* Il faut simplement placer la classe autosubmit sur la balise form
* pour déclencher l'autosoumision du formulaire.
*/
$(function () {
// Dès qu'il y a un changement dans la formulaire.
$(".autosubmit select").on("change", function () {
// On demande confirmation du changement de statut.
if (confirm("Etes-vous sur ?")) {
// L'utilisateur confirme le changement, on change le statut en soumettant le formulaire.
$(this).parents(".autosubmit").submit();
}
else {
// Si l'utilisateur annule le changement, on reset le formulaire pour que le statut ne change pas.
$(this).parents(".autosubmit")[0].reset();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment