Hide component based on field value in custom JS

Hi,

Though I am an experienced Tadabase user, I have forgotten the JS code to hide a specific element based on a condition. I was also looking for the AI helper, but couldn’t find the solution.

So, on a details page, what is the code to do the following?

Whenever fieldvalue_3154 = Yes , hide element_3 and show element_5
Whenever fieldvalue_3154 = No , show element_3 and hide element_5

Could someone please help me?

I always ask Chatgpt first for things like this.

I’m sure someone here can help but you may have a longer wait (we are in the middle of several holidays).

I think you are looking for this:

//Unhide a component
TB.showComponent(‘component_1’)

//Hide Component
TB.hideComponent(‘component_1’)

The code would look like this:


TB.render('component_5’, function(data) {
	if (fieldValue === “Yes”) {
  		TB.hideComponent('component_3’)
  		TB.showComponent('component_5’)
	}  else {
  		TB.hideComponent('component_5’)
  		TB.showComponent('component_3’)
	}
});
1 Like