Help me with accessing dataset fields

Can someone help me? I am trying to make something to check if a field of a specific item from my wix dataset (fuel) is equal to Hybrid Electric, it will show on a text box for that specific car if it is eco friendly or not. I am going to display this on a dynamic page so it will be different for every car in my data collection. Please Help? I do not understand how to write that in Velo. Please Help me.

$w('#dynamicDataset').onReady(() => {
        let itemObj = $w("#dynamicDataset").getCurrentItem();
            if(itemObj.fuel === "Hybrid Electric"){
                // set your textbox value to eco friendly or not here
            }
    })

try this one

@jmtchan Thanks so much! I am trying it and I click run but it will not update and change it for some reason. This is what I have:

Hi Aryav,
As you can see you have a red ~ sign.
This means there is a fault in your code.

Instead of trying to assign to value and text72 at the same time,
try assigning it using 2 lines :slight_smile:

The way you did it is not a working way to do so :slight_smile:

Kind regards,
Kristof.

As what have mentioned above you can’t do what you are trying to do. Instead you can try this code.

$w("#text72").text = "Eco Friendly";
let value = $w("#text72").text;

@volkaertskristof @jmtchan Thank you so much! whenever I change the car page to a different car this error always appears. Please help. Thank you.

try putting your code inside $w.onReady(function () { //here });