Skip to main content
added 74 characters in body
Source Link
Kamil Kiełczewski
  • 93.7k
  • 34
  • 401
  • 375

Short & modern

You cancan catch form input values using FormData and send them by fetchfetch

fetch(form.action, {method:'post', body: new FormData(form)}); 

function send() { let form = document.forms['inputform']; fetch(form.action, {method:'post', body: new FormData(form)}); }
<form name="inputform" action="somewhere" method="post"> <input value="person" name="user"> <input type="hidden" value="password" name="pwd"> <input value="place" name="organization"> <input type="hidden" value="key" name="requiredkey"> </form> <!-- I remove type="hidden" for some inputs above only for show them --><br> Look: chrome console>network and click <button onclick="send()">send</button>

Short & modern

You can catch form input values using FormData and send them by fetch

fetch(form.action, {method:'post', body: new FormData(form)}); 

function send() { let form = document.forms['inputform']; fetch(form.action, {method:'post', body: new FormData(form)}); }
<form name="inputform" action="somewhere" method="post"> <input value="person" name="user"> <input type="hidden" value="password" name="pwd"> <input value="place" name="organization"> <input type="hidden" value="key" name="requiredkey"> </form> <!-- I remove type="hidden" for some inputs above only for show them --><br> Look: chrome console>network and click <button onclick="send()">send</button>

Short & modern

You can catch form input values using FormData and send them by fetch

fetch(form.action, {method:'post', body: new FormData(form)}); 

function send() { let form = document.forms['inputform']; fetch(form.action, {method:'post', body: new FormData(form)}); }
<form name="inputform" action="somewhere" method="post"> <input value="person" name="user"> <input type="hidden" value="password" name="pwd"> <input value="place" name="organization"> <input type="hidden" value="key" name="requiredkey"> </form> <!-- I remove type="hidden" for some inputs above only for show them --><br> Look: chrome console>network and click <button onclick="send()">send</button>

Source Link
Kamil Kiełczewski
  • 93.7k
  • 34
  • 401
  • 375

Short & modern

You can catch form input values using FormData and send them by fetch

fetch(form.action, {method:'post', body: new FormData(form)}); 

function send() { let form = document.forms['inputform']; fetch(form.action, {method:'post', body: new FormData(form)}); }
<form name="inputform" action="somewhere" method="post"> <input value="person" name="user"> <input type="hidden" value="password" name="pwd"> <input value="place" name="organization"> <input type="hidden" value="key" name="requiredkey"> </form> <!-- I remove type="hidden" for some inputs above only for show them --><br> Look: chrome console>network and click <button onclick="send()">send</button>