Vorbly <Code>
CODING MADE EASY WITH VORBLY
WIX CODE PASSING DATA BETWEEN PAGES
Need to pass data between Wix pages? This tutorial will show you how to pass data between your Wix pages using Wix Code. You can now create multi page forms. We will provide you with the webpage elements and sample codes required to implement this feature.
THE DEMO
THE ELEMENTS
Page 1
Text Elements
-
Course Title ID: #title
-
Course Price ID: #price
-
No. of Classes ID: #class
-
Availability ID: #days
Button Elements
-
Sign Up Button: #Submit
Page 2
Text Elements
-
Course Title ID: #title2
-
Course Price ID: #price2
-
No. of Classes ID: #class2
-
Availability ID: #days2
User Inputs
-
Name Field: #name
-
Email Field: #email
-
No. of Sessions Field: #sessions
-
Comments Field: #comments
Button Elements
-
Sign Up Button: #Submit
THE CODE
Page Code 1
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");
}
Page Code 2
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;
});
COMMENTS
I'm a paragraph. Click here to add your own text and edit me. It's easy.