SOLVED

Form follow up URL using a form field value

Go to solution
geordni
Level 2

Form follow up URL using a form field value

I am using a form to capture basic details such as name, email, website. I'd like to use the input from the website field + a predefined set of characters as a follow-up external URL.

 

For example website field is: www.example.com 

Pre-defined characters are: /123XYZ

The follow-up URL would be  www.example.com/123XYZ

 

As form URLs only allow text my.tokens and nested tokens are not possible to use, is there any other way I can achieve the above? 

 

P.S. I have made sure the website field only captures valid websites such as example.com or www.example.com

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Form follow up URL using a form field value


P.S. I have made sure the website field only captures valid websites such as example.com or www.example.com

Not sure what you mean by “valid” here, but if the field Website always contains a hostname and you want to swap that hostname into the Thank You URL:

MktoForms2.whenReady(function(mktoForm){
   mktoForm.onSuccess(function(submittedValues,baseThankYouURL){
      
      let thankYouLoc = document.createElement("a");
      thankYouLoc.href = baseThankYouURL;      
      thankYouLoc.hostname = submittedValues["Website"];  
      
      document.location = thankYouLoc;
      return false;
   });
});

 

You would set the Thank You URL in form editor to a placeholder like https://www.example.com/123456. Then at runtime the www.example.com  is replaced by whatever the Website value was.

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Form follow up URL using a form field value


P.S. I have made sure the website field only captures valid websites such as example.com or www.example.com

Not sure what you mean by “valid” here, but if the field Website always contains a hostname and you want to swap that hostname into the Thank You URL:

MktoForms2.whenReady(function(mktoForm){
   mktoForm.onSuccess(function(submittedValues,baseThankYouURL){
      
      let thankYouLoc = document.createElement("a");
      thankYouLoc.href = baseThankYouURL;      
      thankYouLoc.hostname = submittedValues["Website"];  
      
      document.location = thankYouLoc;
      return false;
   });
});

 

You would set the Thank You URL in form editor to a placeholder like https://www.example.com/123456. Then at runtime the www.example.com  is replaced by whatever the Website value was.

geordni
Level 2

Re: Form follow up URL using a form field value

Thank you so much, this worked!

By "valid" website I meant only example.com or https://example.com are accepted, not simply example or test.