adding an example html form in case we want custom ones

This commit is contained in:
Chris Cochrun 2022-10-30 07:31:53 -05:00
parent c7c150567b
commit 325cf3640a

View file

@ -0,0 +1,36 @@
<script>
function process () {
// (A) GET FORM DATA
var form = document.getElementById("my-form");
var data = new FormData(form);
// (B) AJAX SEND FORM
// NOTE: USE HTTP://. NOT FILE://.
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://n8n.tfcconnection.org/webhook-test/7a23cff5-daa4-4af7-aa64-684185c310e8");
xhr.onload = function () {
console.log(this.response);
form.reset(); // RESET FORM
};
xhr.send(data);
// (C) STOP DEFAULT FORM SUBMIT/PAGE RELOAD
return false;
}
</script>
<form id="my-form" action="https://n8n.tfcconnection.org/webhook-test/7a23cff5-daa4-4af7-aa64-684185c310e8" method="POST" onsubmit="return process()">
<div>
<label for="say">What greeting do you want to say?</label>
<input name="say" id="say" value="Hi" />
</div>
<div>
<label for="to">Who do you want to say it to?</label>
<input name="to" id="to" value="Mom" />
</div>
<div>
<button>Send my greetings</button>
</div>
</form>
</form>