Pulling Field from One Form to Another | Community
Skip to main content
Samantha_Cossum
New Participant
September 17, 2019
Solved

Pulling Field from One Form to Another

  • September 17, 2019
  • 1 reply
  • 4725 views

I am working on a semi-complicated application for our business and have gotten stuck and hoping the Nation can help! 

The desire is to have applicants fill out part one of the form and then when they submit it, it calculates their current collections. I have this part working and the math is firing correctly. 

The part I'm struggling with is on the next section, they are supposed to fill out a target but some of the info needed they just filled out on the page before so I don't want to ask it to them again but I don't know how to get the form to do the calculations if the data isn't in the form. 

Here is the first form: https://go.schedulinginstitute.com/RCBC-App-Target-Collection.html 

Here is the second form: https://go.schedulinginstitute.com/RCBC-App-Testing-2.html 

There's examples on the pages of the math we are trying to do so hopefully that will help if my explanation was unclear. 

The only idea I've had is if I could store the values from the first form in a cookie and then have hidden fields that are populated by the cookie but I couldn't work on how to pull information into a cookie on a form fill. 

Any suggestions would be much appreciated! Thanks! 

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

Certainly a couple of ways to do this. If they're always automatically taken to the next page after filling out the initial form, then you could package the fields in the onSuccess and pass them to the next form, i.e. something like

MktoForms2.whenReady(function(form){
form.onSuccess(function(vals,tyURL){
var tyLoc = document.createElement("a");
tyLoc.href = tyURL;
tyLoc.hash = encodeURIComponent(JSON.stringify(vals));
document.location = tyLoc;
return false;
});
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

If they can get to the next page at a later time, though, use a cookie.

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
September 17, 2019

Certainly a couple of ways to do this. If they're always automatically taken to the next page after filling out the initial form, then you could package the fields in the onSuccess and pass them to the next form, i.e. something like

MktoForms2.whenReady(function(form){
form.onSuccess(function(vals,tyURL){
var tyLoc = document.createElement("a");
tyLoc.href = tyURL;
tyLoc.hash = encodeURIComponent(JSON.stringify(vals));
document.location = tyLoc;
return false;
});
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

If they can get to the next page at a later time, though, use a cookie.

Samantha_Cossum
New Participant
September 19, 2019

Thanks @Sanford Whiteman‌! That seemed to work to get values into the URL (this is my url when I submit the form now https://go.schedulinginstitute.com/RCBC-App-Testing-2.html#%7B%22rCBCCurrentAnnualCollections%22%3A%222000000%22%2C%22rC… ). But how do I pull those values into the next form? If it was in more of a url parameter format I know how I could those into hidden fields but not sure how to pull the values out of this.

Also, is there a way to only pass certain values? I really only need two of them from the first form. 

Really appreciate your help! 

SanfordWhiteman
New Participant
September 19, 2019

On the next page, you can run

MktoForms2.whenReady(function(form){
var hashJSON = document.location.hash.substring(1),
mktoFields = JSON.parse(decodeURIComponent(hashJSON));

form.setValues(mktoFields);
});‍‍‍‍‍‍