Hi community,
I am wondering if it is possible to preselect a specific value within a form picklist based on the URL which led to the form.
For example, if I have a form asking the contact to choose the type of product he is interested in : "HR", "INDUSTRY", "CPA" etc.
Can I automatically display the value "INDUSTRY" if the previous visited page is or contains www.mywebsite.com/industry ?
Your inputs are welcome. Thanks for your help.
Mathias.
Solved! Go to Solution.
MktoForms2.whenReady(function(form){
var referrerTypeTable = {
'INDUSTRY' : [/www\.mywebsite\.com\/industry/],
'HR' : [/www\.mywebsite\.com\/hr/,/www\.mywebsite\.com\/humanresources/],
};
Object.keys(referrerTypeTable).forEach(function(type){
referrerTypeTable[type].forEach(function(pattern){
if (pattern.test(document.referrer)) {
form.setValues({'ProductType':type});
}
});
});
});