Skip to content

Instantly share code, notes, and snippets.

@8ctopotamus
Created June 22, 2021 16:05
Show Gist options
  • Save 8ctopotamus/c4520594ff298ce65e760e8c33d0b453 to your computer and use it in GitHub Desktop.
Save 8ctopotamus/c4520594ff298ce65e760e8c33d0b453 to your computer and use it in GitHub Desktop.
Autofill fields based on query params
window.location.search
.replace('?', '')
.split('&')
.filter(str => !!str)
.forEach(str => {
const [k, v] = str.split('=')
const input = document.querySelector(`[name="${k}"`)
input && (input.value = v)
}, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment