2

On squarespace, is it possible to create a hidden form (or a form out of the view), then use javascript to populate the fields, then call the submit function in the same code?

I am looking for a solution that uses code block to generate the payload then to submit it to squarespace form storage.

Thank you.

Chief680
  • 21
  • 1
  • Hi there. Consider providing a link to the site/page in question and the view-only password (for Squarespace sites in trial mode, set via the Visibility setting). In addition, consider adding more information about what you've tried so far, what's worked and what hasn't. – Brandon Oct 17 '19 at 13:53

1 Answers1

1

Yes, it is possible. It would be done similar to what you describe:

  1. Add a form block to the page in question, setting up the form fields as desired.
  2. Set the form block to display: none;, likely by targeting it via its block-id.
  3. Create your own UI for the user (if needed) via a code block or code injection.
  4. Write JavaScript code that takes the payload, parses it if necessary, matches it with the corresponding fields in the Squarespace form, sets the values, then triggers the form's submit function.
  5. Either set the CSS for the form to show the form block if it's submitted, or write your own submission/success message handler.
Brandon
  • 3,572
  • 2
  • 12
  • 27