SOLVED

Form : preselect a value within a picklist based on referring URL

Go to solution
Anonymous
Not applicable

Re: Form : preselect a value within a picklist based on referring URL

Thanks Sanford, super helpful

SanfordWhiteman
Level 10 - Community Moderator

Re: Form : preselect a value within a picklist based on referring URL

Sure thing!

MannyPerez
Level 1

Re: Form : preselect a value within a picklist based on referring URL

Hey Sanford!

 

I wanted to ask, will this work to set a value based on the current URL they are on for the form? Not sure if thats the same thing as the referrer in this case.

Essentially I want to be able to do something like:
set Brand Name to Brand1 if URL contains /brand1 (i,e. https://www.website.com/brand1)

 

Thanks!

Edit: I think I found the answer in another one of your posts here (https://nation.marketo.com/t5/product-blogs/beautifying-fields-like-last-form-url-by-stripping-unint...

Guessing I can just replace document.referrer with document.location.href to achieve this then.

SanfordWhiteman
Level 10 - Community Moderator

Re: Form : preselect a value within a picklist based on referring URL

document.referrer is the page before you navigated to the current page. document.location.href is the current page.

MannyPerez
Level 1

Re: Form : preselect a value within a picklist based on referring URL

Thank you Sanford! I just found this through another article  of yours and had edited my comment, that works!