samedi 24 mars 2018

How to add checkbox to form submission with jquery?

I am developing a little website with webflow and must now write a tiny bit of custom code. To simplify and summ up, I have a checkbox that is outside fo the form tag. My goal is to write a little jquery of javascript code to "capture" the checkbox outside the form tag and add it to the form submission.

Here is what I came up with, but it's still not working. Would you have an idea ? I'm pretty new to code... thank you :)

The script:

<script>

// defines the variable for the form
var form = document.getElementById("reservation");

// add the checkbox with the id of "outsider" to the form submission
document.getElementById("outsider").addEventListener("click", function () {
  form.submit();
});

</script>




Aucun commentaire:

Enregistrer un commentaire