I am doing a holiday rental site and would like to list all the amenities depending on what they have. Would there be a way to have a field called say ‘pool’ and have yes or no, then display in my repeaters only if there is a yes with an image of a pool? Cheers
I see it is probably booleans, but not sure how to display these please? I will have 2 pool icons (1 grey and 1 black) and if the boolean is ticked then it would show the black, else the grey one. Look forward to your help please!
if (pool === "true"){
$w('#coloredPoolImage').show();
}
else{
$w('#greyPoolImage').show();
}
Should the issue persists, please send us the site URL, the page name and the code you’ve written so that we can better understand what is the scenario.
Leighton, I am doing more or less the same and there are two ways to do it:
on input level: when you define the property in your form, you can use the .onBeforeSave event to check if pool===true and set the image URL for the dark one in a separate image field, else the grey one. Advantage is that you do not have to code on output level. Disadvantage is that you might run into data inconsistency
on output level (=repeater). You can do what Tai suggested above. Downside is that you have to put both images at design time OVER each other to show 1 of them in the same location. Other option is to put the grey one at design time in its place and in code check if the boolean is true. If, so you change the .src to the black one.
Hope this helps.
Oh, and another thing. If it doesn´t work, try dropping the quotes around “true”. As far as I know, you should test ion true, not “true”. It´s not a string.
This is the moment where I start putting in console.log ´s to see where the logic goes wrong. Put one in the if , and one in the else and see what happens.