Pass parameters on a URL after a form completion | Community
Skip to main content
March 24, 2016
Question

Pass parameters on a URL after a form completion

  • March 24, 2016
  • 2 replies
  • 4011 views

I'm familiar with the mechanism to refer the user to a new URL upon completing a form, a la:

<script>

MktoForms2.loadForm("//na-ab07.marketo.com","591-KXC-791", 1124, function(form){

     form.onSuccess(function(values, followUpUrl){

     location.href = "TheNewURLtoVisitNow.com";

     return false;

  });

});

</script>

but how might I pass field values on that URL to the new URL, e.g.:

<script>

MktoForms2.loadForm("//na-ab07.marketo.com","591-KXC-791", 1124, function(form){

     form.onSuccess(function(values, followUpUrl){

     location.href = "TheNewURLtoVisitNow.com?email=email_just_captured&first_name=first_name_just_captured";

     return false;

  });

});

</script>

i.e. I want to capture data on a form, such as email address, first name, last name, company name, and then refer the user to a new URL, passing to the other server/URL 2 or 3 parameters, the value of which is data just entered into the form.

The other server/NEW URL would be our own server, and we want to pass info captured from the form to populate reg fields on our own server.

thx.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Grégoire_Miche2
Level 10
March 24, 2016

Hi David,

It seems to me that you need to refer to the values of the form.

<script>

MktoForms2.loadForm("//na-ab07.marketo.com","591-KXC-791", 1124, function(form){

     form.onSuccess(function(values, followUpUrl){

          var vals = form.vals();

          location.href = "TheNewURLtoVisitNow.com?email="+vals.email+"&first_name="+vals.first"";

          return false;

     });

});

</script>

Just check the extact name of the fields.  (email or first)

-Greg

SanfordWhiteman
Level 10
March 24, 2016

That's what the values param is for:

location.href = 'http://www.example.com' +
'?FirstName=' + values.FirstName +
'&LastName=' + values.LastName;‍‍‍
SanfordWhiteman
Level 10
January 23, 2020

@裕生 田口 since I know you were just looking at this older thread, the code above is actually wrong.

It must be:

location.href = 'http://www.example.com' +
'?FirstName=' + encodeURIComponent(values.FirstName) +
'&LastName=' + encodeURIComponent(values.LastName);