onReady expand or show element

I have a button on a dynamic item page that is collapsed. I want to expand that element if one of my dropdown’s value = X
However, the value of that dropdown is entered on a different page. Therefore, I cannot expand the button by adding an “onChange” nor an “onClick” event to the dropdown menu cause the value is already input.

In other words, I want the collapsed button to expand onReady if the pre determined dropdown value is = X.

Any help on this is much appreciated! Thank you!

You can use the wix-storage API to store values and share them with pages in the site.

First, you need to import the API:
import {session} from ‘wix-storage’;

On the page with the dropdown, you can save the returned value like this:
session.setItem(“key”, “value”);

To retrieve the value on another page:
let value = session.getItem(“key”);

Good luck,

Yisrael

Thank you Yisrael for your help as always.

However, I am not sure the wix-storage will do the job.

I am trying to retrieve an item from a collection on ready, when the page loads.

import wixData from ‘wix-data’;
$w.onReady( function () {
wixData.get(“Referrals”, “topic”)
.then( (res) => {
($w(‘#dropdown12’).value) = res.item;
})
. catch ( (err) => {
let errorMsg = err;
} );

So basically, the “topic” is stored in a collection by one user. then I want the dropdown12 value to be retrieved from topic when a different user is on the page. The code above did not work, can i get an item from a collection onReady?

A get() uses the item’s id . Also, you need to specify what field contains the item that you need. Something like this:
$w(’ #dropdown12 ').value = res.item.field; // where field is the name of the field with the value you need