Check active tab and run code

I can only seem to find how to do this in the wizard control. But I would like to check what the active tab is in the tab control (Tab1 in this instance) and then run code depending on this.. Is there any way to also check if the active tab has been changed as well (e.g. from tab index 5 to tab 0)? At the moment I am just calling the function with setInterval, but this is not ideal!

What I am trying to do is to filter a lookup field based on the current selected tab. I can filter the lookup in js but this is currently static and I would like it dynamic when a tab is changed.



I had one final search of the forum and found a previous solution, thanks!

       console.log('tab index changed');
       if(fd.container('Tab0').currentTab == 0) {
       //filter if the first tab selected
       if (fd.container('Tab0').currentTab == 1)
       //filter if the second tab selected
1 Like

Dear @Nathan,
You can always use the following code to get index of the currently active tab (starting with 0):

var activeTab = fd.container('Tab1').currentTab;
if(activeTab == 0){
  //do something

You can also check for changes this way as well:

  alert('Switched tab!');
1 Like