Pass parameters on a URL after a form completion

Anonymous
Not applicable

Pass parameters on a URL after a form completion

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 = "http://www.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 = "http://www.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.

3 REPLIES 3
Grégoire_Miche2
Level 10

Re: Pass parameters on a URL after a form completion

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 = "http://www.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 - Community Moderator

Re: Pass parameters on a URL after a form completion

That's what the values param is for:

location.href = 'http://www.example.com' +
'?FirstName=' + values.FirstName +
'&LastName=' + values.LastName;‍‍‍
SanfordWhiteman
Level 10 - Community Moderator

Re: Pass parameters on a URL after a form completion

裕生 田口 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);