Skip to content

Instantly share code, notes, and snippets.

@smks
Created November 12, 2016 20:11
Show Gist options
  • Save smks/30ccb2095da360cff7e8cb1c9b0b7d8e to your computer and use it in GitHub Desktop.
Save smks/30ccb2095da360cff7e8cb1c9b0b7d8e to your computer and use it in GitHub Desktop.
var formElement = document.createElement('form');
formElement.setAttribute('method','post');
formElement.setAttribute('action','login.php');
var usernameField = document.createElement('input');
usernameField.setAttribute('type','text');
usernameField.setAttribute('name','username');
var passwordField = document.createElement('input');
passwordField.setAttribute('type','password');
passwordField.setAttribute('name','password');
var submitField = document.createElement('input');
submitField.setAttribute('type','submit');
submitField.setAttribute('value','Submit');
formElement.appendChild(usernameField);
formElement.appendChild(passwordField);
formElement.appendChild(submitField);
document.body.insertBefore(formElement, document.body.childNodes[0]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment