I’ve got a site with articles (~ blog posts) built with CMS, and there is a Submission Form below EACH article.
So, people can submit an inquiry that may relevant to that specific article they are currently visiting.
How to allow Webflow Forms to get the current article’s URL? The goal is to let our side being able to receive emails with that URL, so that we can better follow-up the case.
The following code is bad practice (having multiple IDs with the same name) but this code will work for either IDs or classes on your inputs.
<script>
(function getURL() {
const inputs = document.querySelectorAll('#url')
for (var i = 0; i < inputs.length; ++i) {
var input = inputs[i];
let url = window.location.href;
input.value = url;
};
})();
</script>
You can paste this is in the footer code from your website dashboard…because you’ll want to make sure the elements exist before attempting to iterate through them.