Help! How to pass data from one dynamic page to another

I have one page that displays product types using a Repeater connected to a DataSet. When the user clicks one of the items, I need to be able to navigate to another page that displays all of the products of the selected type - using another Repeater, connected to another DataSet.

How can I do this? Thanks!

1 Like

Please help - I am stuck and need to keep moving. Thanks!

Use storage, session or local. Storage - Velo API Reference - Wix.com

Hi Ben,

Do you mean you want to create a filter or category page? When visitor select one of the category, jumping or showing product data, which refer to category selected.

I have one page that displays a job description and a button to souscribe. When the user press that button i want to show another page that displays a form that the user will fill. but how can i show to title of the job on the second page ?

Hi Patrick,

Any luck with your quire? I’m also looking for the same answer.

Hey Stephen,

The quickest way to pass that data would be session storage, which would look something like this.

On Page A

import {session} from 'wix-storage';

function anyFunction(){
     session.setItem('my_item_key',item);//Keep in mind, 'item' must be a string.
}

On Page B

import {session} from 'wix-storage';

function needsTheData(){
     let result = session.getItem('my_item_key'); //Where result will be a string.
}

The reasons we use session and not local is that I’m presuming data passed between pages should be session specific, you wouldn’t want to see it again when you reopen the browser.
To remove the data you can use session.clear() for all data or session.removeItem(‘my_item_key’) for each piece of data.

Hi Chris,

Thank you for your reply, its very much appreciated. I have a separate thread that is a little more specific if you wouldn’t mind taking a look?

In the code where it displays (‘my_item_key’) is this referring to the the ID of the field? or a field key from a database?

Thanks again

Stephen

Hey Stephen,

It’s actually any key that you decide on, not linked to the database or the id. So if you’re storing a store category from a click for example, you could say session.setItem(‘storeCategory’,categoryFromClick);

Hi Derrell,

I think I’m starting to understand, so basically you provide a key for the other page to be able to refer to? the thing that is confusing me is how does either page know what the value of the field you are transferring from/to is?

Also the page I’m trying to transfer the info from is a dynamic page to standard page, so the data will be different if the on_click is used depending what course the customer is looking at.

The below example is from a dynamic page, this displays a chosen course but with different dates, if the customer likes the look of the start date in #date3 then clicks bookhere3, this will redirect them to a standard page for details and payment

I’m looking to get the details from the above fields to prefill the fields on the page below

Again, thank you for your help, I really appreciate your time and effort.

Did you find a solution to this ?

I found a solution that works for the data transfer to the new page, but can’t get it to work for the relevant button clicked… not sure if that’s of any help?

Thanks everyone! I got it :slight_smile:

P.S. I am just carrying the Price over so that I can setup a Stripe Payment API on the 2nd Page. The data from Page 1 however goes into a Database before redirecting to Page 2.

It works for me, you need to set a On View Port Enter for the second Page.

My First Page:

My First Page Code:

$w.onReady( function ()  {
getsum();
});

function getsum()  {
    const totalprice =  (Number($w('#dropdown1').value)*40) + (Number($w('#dropdown2').value)*20);
    $w('#text5').text =String(totalprice);
        
}

export function dropdown1_change_1(event, $w) {
	getsum(); 
}

export function dropdown2_change_1(event, $w) {
	getsum();
}


import {session} from 'wix-storage';

export function button1_click(event, $w) {
	//Add your code for this event here: 

session.setItem('price', $w('#text5').text);

}

My Second Page

My Second Page Code

import {session} from 'wix-storage';



export function text2_viewportEnter(event, $w) {
	//Add your code for this event here: 
const price = session.getItem('price');

$w('#text2').text = price;

}

Hope this Helps you :slight_smile:

Take Care,

Shan