Skip to content

Instantly share code, notes, and snippets.

@anmolsukki
Created February 14, 2021 06:45
Show Gist options
  • Save anmolsukki/821a0321bf9c83383fcbc541340f336b to your computer and use it in GitHub Desktop.
Save anmolsukki/821a0321bf9c83383fcbc541340f336b to your computer and use it in GitHub Desktop.

Submit Form Data with Templating

var form = document.createElement('form');
var element1 = document.createElement('input');
var element2 = document.createElement('input');
var element3 = document.createElement('input');
form.method = 'POST';
form.action = response.data.url;
element1.value = response.data.Name;
element1.name = 'name';
element1.type = 'hidden';
form.appendChild(element1);
element2.value = response.Mobile;
element2.name = 'mobile';
element2.type = 'hidden';
form.appendChild(element2);
element3.value = response.data.Email;
element3.name = 'emaol';
element3.type = 'hidden';
form.appendChild(element3);
document.body.appendChild(form);
form.submit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment