I have a details page and I want to change the background colour of a details component based on a condition. I want to show it either blue or yellow. The color should be applied to the whole of the details component. How can I edit this? I can’t find the relevant controls in the TB portal.
@slimpens you’ve clicked in the wrong ‘Display Rules’ thats all… you need to click on your date field first. This will give you the ‘Display Rules’ for the field as shown below:
@slimpens You can use the javascript tab for this. On the front end page use the inspector tool to find out what the components ID # is and then you can add this code:
TB.render('component_3', function(data) {
let status = "{pageField.Status}"; // You can set this value as needed
// Check if the status is "active"
if (status === "Active") {
// Select the element by its ID and change its background color
document.getElementById("x_element_page_168_3").style.backgroundColor = "blue";
}else{
document.getElementById("x_element_page_168_3").style.backgroundColor = "red";
}
});
Make sure you change the ‘component_3’ to whatever your component is.
Update the “{pageField.Status}” to the field you want to set as the condition.
Update the “Active” to whatever your conditional value is.
Update “x_element_page_168_3” with the ID of your component.