Webflow sync, pageviews & more.
NEW

How can I pull the stored email from the first form submitted on our website and input it into a field on a later form during the sign-up process in Webflow? I have tried using the provided script but it only displays "undefined" in the field. I don't have much knowledge of JavaScript and found this script online.

TL;DR
  • Use JavaScript on the first form page to save the submitted email to localStorage after form submission.
  • On the second form page, retrieve the saved email from localStorage and prefill the email input field using matching name or selector.

You're trying to capture a user's email from one form submission and later pre-fill another form field with that same email on a different page or step. If the script you're using shows "undefined", it likely means the email is not being properly stored or retrieved.

1. Store the Email in Local Storage After First Form Submission

  • In the Page Settings or using an Embed element on the same page as the first form, insert custom JavaScript to store the email after they submit.

  • Use the localStorage API to save the email address.

  • Here's a simplified version that works with Webflow forms:

    Place this in the Footer section of your page settings (or an Embed block):

    ```javascript

    ```

  • Important: Make sure your form has an email input of type="email".

2. Use JavaScript to Prefill a Field on the Later Form

  • On the sign-up form page, insert a script to retrieve the email from localStorage and set it into the right field.

  • Again, place this in the Footer section or Embed element:

    ```javascript

    ```

  • Match the input name: If the second form's email field has a different name attribute (e.g., name="user_email"), update querySelector accordingly.

3. Troubleshooting “Undefined”

  • Check if the first form actually runs the script. You might be saving undefined if the script runs before the form is filled out.

  • Ensure the first form has submitted before testing the second page.

  • If using Webflow's interactions instead of a default form submission, the event listener may not fire. Use "w-form-done" in that case:

    ```javascript
    $('.w-form-done').on('DOMSubtreeModified', function () {
    const email = document.querySelector('input[type="email"]').value;
    localStorage.setItem("savedEmail", email);
    });
    ```

Summary

To pass an email from one Webflow form to another:

  • Store the email in localStorage after the first form submission using a script.
  • Retrieve and prefill it on the later form using another script.
  • Be sure the form field names match what the script is targeting, and that the form submits before testing the second form.
Rate this answer

Other Webflow Questions