Submit two forms via one submit button

Hi guys,

I’m stuck here.

The way that it is currently set up is that the user fills in a small form on the homepage, which then redirects them to a multistep form on another page. I would like the data from both forms to be submitted as one (instead of two separate submissions). Is this possible?

Thanks in advance.

Hello,

In order to implement this you will need to use Storage API https://www.wix.com/corvid/reference/wix-storage.Storage.html

Note: it’s not possible to implement this using Wix Forms.

Refer to the examples below that should help you start creating custom forms:
Creating a Form with User Input Elements
Multistage Forms

You would be better suited going through Wix Customer Care if you have more questions about Wix Forms.
https://support.wix.com/en/article/contacting-wix-customer-care-for-support

Hi,

Could you show me what this code would look like?

I created the custom forms but I can’t seem to figure out how to implement the Storage API.

The Storage API contains examples that you can use and modify to suit your own site.
https://www.wix.com/corvid/reference/wix-storage.html

How do I pass data between pages in my site?
Use the wix-storage API. Use the setItem() function to place data in storage on the originating page. Then use the getItem() function to retrieve the data on the target page.

Example.

import wixLocation from "wix-location";
import {session} from 'wix-storage';

export function submit_click(event, $w) {
session.setItem('title', $w('#title').text);
session.setItem('price', $w('#price').text);
session.setItem('class', $w('#class').text);
session.setItem('days', $w('#days').text);
wixLocation.to("/page2");
}

================================================

import {session} from 'wix-storage';

$w.onReady(function () {

const title2 = session.getItem('title');
const price2 = session.getItem('price');
const class2 = session.getItem('class');
const days2 = session.getItem('days');

$w('#title2').text = title2;
$w('#price2').text = price2;
$w('#class2').text = class2;
$w('#days2').text = days2;
});

Hello,

Thanks for your help. I’m still new to this as you can probably tell.

The only thing that I haven’t figured out is how I can save the session data (that I retrieved from the first page) to my database when I press the submit button on the second page.

Help would be greatly appreciated.