URLSearchParams in the "Before </body> tag" section of the Custom Code settings to extract URL query parameters and auto-fill form fields in Webflow.To auto-fill form values in Webflow using data from the URL query string, you need to extract query parameters and map them to form fields.
? and contain key-value pairs separated by &, such as ?name=John&email=john@example.com.
URLSearchParams to loop through key-value pairs:
document.addEventListener('DOMContentLoaded', function() {
const urlParams = new URLSearchParams(window.location.search);
urlParams.forEach(function(value, key) {
const inputElement = document.querySelector(`[name="${key}"]`);
if (inputElement) {
inputElement.value = value;
}
});
});
/form-page?name=John&email=john@example.com.
To auto-fill Webflow form values using URL query strings, add custom JavaScript to extract and apply query parameters to corresponding form fields.