tags:

views:

31

answers:

1

Hello,

I have several tabs that my site changes between using Javascript. When ever a tab is clicked I need to know which one it was and which one I am currently on.

I have done this through the use of if functions(lots!). I now want to add a new tab and I have to expand all my if functions etc.

Is there a different implementation I can use for this, so future adding of tabs is easy and I don't have to use so many if functions.

I hope I made sense and there is a solution.

+3  A: 

The obligatory answer: Use jQuery, and then use jQuery Tabs. The Tabs plugin generates callbacks that pass to it both the tab being shown and the tab being hidden, which should work nicely for you.

If for some reason you are masochistic and enjoy writing plain Javascript for no apparent reason, then you need to post the code you are using so we can better help you.

Paolo Bergantino
Masochistic? Holy cow, don't you think that's a little extreme?!
Josh Stodola
It was tongue in cheek, mostly. :)
Paolo Bergantino
I hope so because it is very critical and presumptuous. I am making use of JQuery already and I am a bearer of the code reuse flag but on this occasions I was not aware of JQuery having this feature. Thanks for pointing me in the right direction. Tongue in cheek of course. ;)
Abs