# Displaying rich text from a CMS depending on data from an earlier page

**URL:** <https://forum.wixstudio.com/t/displaying-rich-text-from-a-cms-depending-on-data-from-an-earlier-page/74085>\
**Category:** Ask the community\
**Tags:** wix-storage-frontend, code, cms, question, wix-studio\
**Created:** [October 7, 2025, 5:05pm UTC](https://forum.wixstudio.com/t/displaying-rich-text-from-a-cms-depending-on-data-from-an-earlier-page/74085 "2025-10-07T17:05:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eglass](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@eglass](https://forum.wixstudio.com/u/eglass)\
**Post date:** [October 7, 2025, 5:05pm UTC](https://forum.wixstudio.com/t/displaying-rich-text-from-a-cms-depending-on-data-from-an-earlier-page/74085/1 "2025-10-07T17:05:12Z")

</div>

**I’m having trouble with**  
Displaying rich text from a CMS on a page depending on data from an earlier page using sessions.

**Working in**  
Wix Studio Editor

**Site link**  
Not live yet, I can only share code snippets and screenshots.

**What I’m trying to do**  
User answers radio-button questions. On a summery page, the radio-button group value is brought in, I’m using sessions, to display different text content for each radio-button choice. This text content is brought in from a CMS. The CMS contains the text content and the value of the radio-button group.

**What I’ve tried so far**  
I’ve referenced Velo Documentation from [Wix-Storage](https://dev.wix.com/docs/velo/apis/wix-storage-frontend/introduction), I’ve used WIX code ai generator, and ChatGPT. ChatGPT had outdated code that no longer works.

But maybe the issue is my syntax?

```javascript
// used set value
import { session } from "wix-storage"; // added to the top
let selectedValue = event.target.value; // within onChange for the radioButtonGroup
session.setItem("AboutHealth1", selectedValue ); // code used to set the value

// used to get item value on another page
import { session } from "wix-storage"; // added to the top
let savedChoice1 = session.getItem("AboutHealth1") // used to receive the value

// used to retrieve the content to be displayed from the CMS ID="Results"
 wixData.query("Results")
            .eq("title", savedChoice1)
            .find()
            .then((results) => { ... }); // used to get the corresponding cell in the CMS

// more code I used on request

```

**Extra context**  
Anything else that might help - edge cases, screenshots, etc.

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [October 10, 2025, 1:35pm UTC](https://forum.wixstudio.com/t/displaying-rich-text-from-a-cms-depending-on-data-from-an-earlier-page/74085/2 "2025-10-10T13:35:16Z")

</div>

Again you? 😁

> [@Saving radio button values to display later on](https://forum.wixstudio.com/t/saving-radio-button-values-to-display-later-on/73660/7):
>
> Ok, back again to your problem. Looking onto your description and the very good and informative video of AMANDA (Wix-Team), i think your problem is not about the Wix-Storage. I think it is more about how to setup your wanted functionality the right way. The Video clearly explains everything about how Wix-Storage is working. Your aim is what? You want to transfer a value from PAGE-A to PAGE-B, right? I want a value from a radio button to be passed to a “conclusion” page So somewhere on PA…

I thought you have resolved your issue already, since there was no answer 🤔 🤔 🤔

**Hopefully the following code is not the full version** —\>

```javascript
// used set value
import { session } from "wix-storage"; // added to the top
let selectedValue = event.target.value; // within onChange for the radioButtonGroup
session.setItem("AboutHealth1", selectedValue ); // code used to set the value

```

**Surely you will have something like…** (simple-version)..

```javascript
import { session } from 'wix-storage';

$w.onReady(function () {
    const radioGroup = $w('#radioGroup1');

    radioGroup.onChange(() => {
        const selectedValue = radioGroup.value;
        session.setItem('AboutHealth1', selectedValue);
        console.log('Saved to session:', selectedValue);
    });
});

```

**…on → PAGE-A.**

You just have stored some data for the → AboutHealth1 ← key, into your Wix-Storage-Session.

Now all you need is to retrieve that stored data on → PAGE-B ← back again…

### 📄 **Page B – retrieve the stored value**

```javascript
import { session } from 'wix-storage';

$w.onReady(function () {
    const savedValue = session.getItem('AboutHealth1');
    if (savedValue) {console.log('Retrieved from session:', savedValue);
        // Example: set the value in another RadioGroup
        $w('#radioGroup1').value = savedValue;
    } else {console.log('No value found in session.');}
});

```

**So what would be your next step now?**  
You have already your key-string from page-A on page-B already.  
What do you wanna do with that information on page-B ?

> [Displaying rich text from a CMS depending on data from an earlier page](https://forum.wixstudio.com/t/displaying-rich-text-from-a-cms-depending-on-data-from-an-earlier-page/74085)

**So you have this already…**

```javascript
// used to retrieve the content to be displayed from the CMS ID="Results"
 wixData.query("Results")
            .eq("title", savedChoice1)
            .find()
            .then((results) => { ... }); // used to get the corresponding cell in the CMS

```

Make an own FUNCTION out of it… (turning it into an own returning function)…  
So it could look (_on page-B_) something like …

```javascript
import wixData from 'wix-data';
import { session } from 'wix-storage';

$w.onReady(async function () {
    const items = await get_filteredData();

    if (items.length > 0) {
        const item = items[0]; // first matching record
        console.log('Matched CMS item:', item);

        // 🧩 Example: populate your page
        $w('#textTitle').text = item.title;
        $w('#textDescription').text = item.description;
        $w('#image1').src = item.image;
    } else {
        console.log('No matching records found.');
    }
});

async function get_filteredData() {
    const savedChoice1 = session.getItem('AboutHealth1');
    if (!savedChoice1) {
        console.warn('No savedChoice1 found in session storage');
        return [];
    }

    try {
        const results = await wixData.query('Results')
            .eq('title', savedChoice1)
            .find();

        console.log(`Found ${results.items.length} results for`, savedChoice1);
        return results.items;
    } catch (err) {
        console.error('Error querying Results:', err);
        return [];
    }
}

```

**Tweak it even more to make it more dynamic and reusable…**

```javascript
import wixData from 'wix-data';
import { session } from 'wix-storage';

const myCollection = 'ID OF COLLECTION HERE;' //(or name)

$w.onReady(async()=> {
    const savedChoice1 = session.getItem('AboutHealth1'); console.log('Saved-Choice1: ', savedChoice1);
    const items = await get_filteredData(savedChoice1);
    if (items.length > 0) {console.log('Items have been found!');
        const item = items[0]; console.log('Matched CMS item:', item);
        // 🧩 Example: populate your page
        $w('#textTitle').text = item.title;
        $w('#textDescription').text = item.description;
        $w('#image1').src = item.image;
        // ...and so on...
        // ...and so on...
        // ...and so on...
        // ...and so on...
    } else {console.log('No items have been found.');}
});

async function get_filteredData(data) {    
    if (!data) {console.warn('No savedChoice1 found in session storage'); return [];}
    try {
        const results = await wixData.query(myCollection).eq('title', data).find();
        console.log(`Found ${results.items.length} results for`, data);
        return results.items;
    } catch (err) {console.error('Error querying Results:', err); return [];}
}

```

**So what exactly happens now on page-B ???**  
Yes you are right! → The DATA-STRING is pulled out from your Wix-Storage (session) on page-B automatically now and is used to filter your collection based on the STRING from the storage → meaning the STRING from your PAGE-A (which have been selected inside the RBG on page-A).

# What you have learned so far?

1. How to store **DATA to the Wix-Storage**.
2. How to retrieve **DATA from Wix-Storage**.
3. How to use **Wix-Data**.
4. How to **FILTER based on VALUES**.
5. How to generate **RETURNING FUNCTIONS**.
6. When and how to use → **ASYNC-AWAIT** combos.
7. How to keep your setup modular and reusable.

---

<div class="post-metadata">

**Author:** ![eglass](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@eglass](https://forum.wixstudio.com/u/eglass)\
**Post date:** [October 14, 2025, 2:27pm UTC](https://forum.wixstudio.com/t/displaying-rich-text-from-a-cms-depending-on-data-from-an-earlier-page/74085/3 "2025-10-14T14:27:46Z")

</div>

Yes, the issue was I was missing the ‘async’ .

You are most helpful. Thank you so much.

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [October 14, 2025, 6:30pm UTC](https://forum.wixstudio.com/t/displaying-rich-text-from-a-cms-depending-on-data-from-an-earlier-page/74085/4 "2025-10-14T18:30:43Z")

</div>

Glad you were able to resolve it.  
 ![bcabb205-05fd-443e-ad70-6244b69b6194](https://us1.discourse-cdn.com/wix/original/3X/e/9/e92a040583500c23e3169721768f7eddcb94fbce.gif)
