hello,
I have a drug database with a boolean type field (field key = enStock)
In my dynamic page , the text box (Stock) connected to boolean field display “true” or “false” if my boolean field is ticked or not.
I need in the text box the word “OUI:” if it is true or “NON:” if it is false
Thanks for your help
Hi,
Use getCurrentItem as explained below to get the currently selected item.
The code should look like this:
$w.onReady(() => {
$w("#dynamicDataset").onReady(() => {
let itemObj = $w("#dynamicDataset").getCurrentItem();
if (itemObj.isInStock) { //make sure that the "isInStock" field matches the one in you collection
$w('#isInStockText').text = "OUI";
}
else {
$w('#isInStockText').text = "NOU";
}
});
});
Hi,
Thank you very much for your answer
I think I’m making a code mistake, I still get “True” or ""false
screenshot in attachment
You have some syntax errors in your code
Are you trying to execute this function in the viewPortEnter event?
If so, remove the $w.onReady() => line and add a } at the end.
Hi,
Thank you
I’m sorry, I dont know how to execute the function in the viewPortEnter event
I show you my code syntax errors in line 11, 12 and 13

Try this
import wixData from 'wix-data';
export function text43_viewportEnter(event) {
$w.onReady(() => {
$w("#dynamicDataset").onReady(() => {
const itemObj = $w("#dynamicDataset").getCurrentItem();
if (itemObj.enStock) {
$w('#text43').text = "OUI";
} else {
$w('#text43').text = "NON";
}
});
});
}
Hi,
great, it works, i’m happy
thank you very much
Hello @admin-23 , I am trying to do the same thing . Please help me out. This is the screenshot where I have already used some code. Now I don’t understand where to add the code you provided…
I want to show text “Photographer” instead of showing True for the textbox which has id “category1” …
the fieldname is “photographer”…
And I need to do the same for the other texts where “category” is written. Please help me out
How can I do it with Icons? I would like to add an Icon/Img instead of text
How can I do it with an img instead of text?
Please add this as a new forum post rather than bumping an old thread from 2018.
Include a link to refer back to this post if needed.
Old post being closed.