Created
January 17, 2019 00:31
-
-
Save josephting/4aceb5bbe0a5537bbcfd2eda7e0c2002 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><html lang='en' class=''> | |
<head><title>Auto-populate form with query string</head><body> | |
<form> | |
<p> | |
<label>Email Address | |
<input type="email" name="email" id="email"> | |
</label> | |
</p> | |
<p> | |
<label>Subject | |
<input type="text" name="subject" id="subject"> | |
</label> | |
</p> | |
<p> | |
<label>Message | |
<textarea name="message" id="message"></textarea> | |
</label> | |
</p> | |
<p><button type="submit">Send</button></p> | |
</form> | |
<script> | |
var urlParams = new URLSearchParams(window.location.search); | |
document.getElementById('email').value = urlParams.get('email'); | |
document.getElementById('subject').value = urlParams.get('subject'); | |
document.getElementById('message').innerHTML = urlParams.get('message'); | |
</script> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment