Search code examples
javascriptphpjquerywordpressgravity-forms-plugin

pre populate Gravity Forms dropdown depending on directing link


On my Wordpress Site, I have a contact page with a Gravity Form inside. The first dropdown selector in that form has choices to...

  • Contact Tim
  • Contact Lee
  • General Enquiry

There are several links around the site leading to this contact page. Is there any way to make that first dropdown pre selected depending on which link you have come from? eg. If you click the 'Contact me' link on Lee's page the form would automatically have that dropdown set to 'Contact Lee'

Thanks in advance


Solution

  • You can use dynamic population to populate an input on your form from a parameter in the query string.

    For example, if they're coming from Tim's bio page, you could populate the link on that page like so:

    http://yoursite.com/contact/?type=Contact%20Tim

    You would then set the dynamic population parameter on your choices field to "type" so it will pick up the "type" parameter from the query string.