title: prefill Marketo fields on Submit
body: <p>On submit of Marketo form it does some processing and returns back to the same page.</p>
  
  <p><strong>My requirement</strong></p>
  
  <p>I would like to have all the Marketo fields populated with the just entered data (data entered before clicking Submit button)for all the Marketo fields.</p>
  
  <p><strong>What I have tried</strong></p>
  
  <p>I have used the below code, that's given in <a href="http://developers.marketo.com/blog/external-page-prefill/" rel="nofollow noreferrer">http://developers.marketo.com/blog/external-page-prefill/</a></p>
  
  <pre><code>&lt;script&gt;
  MktoForms2.whenReady( function(form) {
      //set the first result as local variable
      var mktoLeadFields = mktoLead.result[0];
      //map your results from REST call to the corresponding field name on the form
      var prefillFields = { 
              "Email" : mktoLeadFields.email,
              "FirstName" : mktoLeadFields.firstName,
              "LastName" : mktoLeadFields.lastName,
              "Company" : mktoLeadFields.company
              };
      //pass our prefillFields objects into the form.vals method to fill our fields
      form.vals(prefillFields);
      }
      );
  &lt;/script&gt;
  </code></pre>
  
  <p>But when the form submits and loads\returns back its not populated with previos entered data</p>