Streaming live at 10am (PST)

Pre-Populating A Form w/ URL Parameters


#1

Hello - I'm looking for some pointers on how to pass URL params into webflow in order to pre-populate a form. It doesn't appear there is a productized feature to handle this. I gather this will require some custom JS and Div Tags.

Here is an example URL from our site: http://hirely-mvp.webflow.io/employer

I would like to accomplish this:
http://hirely-mvp.webflow.io/employer?business=starbucks&var="param2"&var="param3 etc

And then use the URL params to pre-populate displayed and hidden form fields in a WebFlow data collection.

Thanks everyone for any tips or tricks before I go and try to hack this thing together!


Here is my public share link: LINK
(how to access public share link)


URL parameter - checkbox - preloading form
#2

You need to paste this in the "Page Settings" > "Before body tag" textarea field of your page:

<script>
function getParam(name) {
  name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
  results = regex.exec(location.search);
  return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
var Webflow = Webflow || [];
Webflow.push(function() {
    $('#Business').val(getParam('business'));
    $('#email').val(getParam('email'));
});
</script>

Now this link will work:

http://hirely-mvp.webflow.io/employer?business=starbucks&email=test@example.com


#3

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.