# getTabFormNameAt question

**URL:** <https://forum.servoy.com/t/gettabformnameat-question/11016>\
**Category:** Classic Servoy\
**Created:** [August 5, 2009, 4:49pm UTC](https://forum.servoy.com/t/gettabformnameat-question/11016 "2009-08-05T16:49:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ron](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@Ron](https://forum.servoy.com/u/Ron)\
**Post date:** [August 5, 2009, 4:49pm UTC](https://forum.servoy.com/t/gettabformnameat-question/11016/1 "2009-08-05T16:49:29Z")

</div>

Hi all,

I have a mainform with a tabpanel.  
The first tab is selected.  
This is the code that works:  
var \_tabindex = elements.maintabs.tabIndex  
if(\_tabindex ==1){ elements.tab1.bgcolor = ‘#FFFFFF’ }  
if(\_tabindex ==2){ elements.tab2.bgcolor = ‘#FFFFFF’ }

But I want to do something like this, but it does not work.  
var \_tabindex = elements.maintabs.tabindex  
var \_tabname = elements.maintabs.getTabFormNameAt[\_tabindex]  
elements[\_tabname].bgcolor = ‘#FFFFFF’

If I put the recordindexnumber (and not the var \_tabindex) in getTabFormNameAt, it will run, but  
than I have to make if or case statements also, I guess this is the only way.

Thx.

---

<div class="post-metadata">

**Author:** ![lvostinar](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/lvostinar/32/5248_2.png) [@lvostinar](https://forum.servoy.com/u/lvostinar)\
**Post date:** [August 6, 2009, 8:28am UTC](https://forum.servoy.com/t/gettabformnameat-question/11016/2 "2009-08-06T08:28:56Z")

</div>

getTabFormNameAt is a function so, should be: var \_tabname = elements.maintabs.getTabFormNameAt(\_tabindex); also this will be the name of the form on the tab , to get the tab name use: getTabNameAt

---

<div class="post-metadata">

**Author:** ![Ron](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@Ron](https://forum.servoy.com/u/Ron)\
**Post date:** [August 6, 2009, 10:32am UTC](https://forum.servoy.com/t/gettabformnameat-question/11016/3 "2009-08-06T10:32:24Z")

</div>

Thanks sofar Ivostinar.  
So you mean this should work:

var \_tabindex = elements.maintabs.tabIndex  
var \_tabname = elements.maintabs.getTabNameAt(\_tabindex)  
elements[\_tabname].bgcolor = ‘#FFFFFF’

it returns an error: cannot set property “bgcolor” of undefined…

I checked and \_tabindex returns a number (‘1’ or ‘2’, since I have two tabs).

this: var \_tabname = elements.maintabs.getTabNameAt(1) also returns nothing, I expected to see ‘tab1’  
evenso: var \_tabname = elements.maintabs.getTabNameAt(\_tabindex)

elements.tab1.bgcolor = ‘#FFFFFF’ , sets the first tabcolor to white.

Ron

---

<div class="post-metadata">

**Author:** ![sanneke](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@sanneke](https://forum.servoy.com/u/sanneke)\
**Post date:** [August 6, 2009, 11:12am UTC](https://forum.servoy.com/t/gettabformnameat-question/11016/4 "2009-08-06T11:12:49Z")

</div>

Hi Ron,

I think what you are looking for is this:

elements.maintabs.setTabBGColorAt(\_tabIndex, ‘#FFFFFF’ )

---

<div class="post-metadata">

**Author:** ![Ron](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@Ron](https://forum.servoy.com/u/Ron)\
**Post date:** [August 6, 2009, 1:15pm UTC](https://forum.servoy.com/t/gettabformnameat-question/11016/5 "2009-08-06T13:15:45Z")

</div>

I now see what I am doing wrong.  
I use custom tabs.  
The tabs in my tabpanel have no name property.  
Since my custom tabs are named tab1, tab2 etc. I think I  
can use the tab index to set the colors of the custom tabs with a loop.  
Thank you both for your time.

Ron
