0

I have an <apex:tabPanel> with several <apex:tab>.

In my first tab, I have an <apex:commandButton> and I want to switch to the second tab after a click on it. Is it possible ?

Here is my VisualForce page :

<apex:page>
 <apex:tabPanel>
     <apex:tab label="tab1" name="tab1" id="tab1">
         <apex:commandButton onclick="switchToSecondTab()"/>    
     </apex:tab>
     <apex:tab label="tab2" name="tab2" id="tab2">

     </apex:tab>
 </apex:tabPanel>

<script type="text/javascript">>
    function switchToSecondTab() {
        // What do I need to do here to switch to tab2 ?
    }
</script>
</apex:page>

2 Answers 2

1

Have u tried this [ http://www.infallibletechie.com/2013/02/blog-post.html ]

May this will help you !!!

0
1

Thanks to @Aryan kapoor's link and with some modifications, I can do what I want.

Here is the code :

VisualForce page :

<apex:page>
     <apex:tabPanel switchType="client" id="panelId" value="{!tabOpt}">
         <apex:tab label="one" name="one" id="one">
             <apex:commandButton action="{!switch}" rerender="panelId"/>    
         </apex:tab>
         <apex:tab label="two" name="two" id="two">

         </apex:tab>
     </apex:tabPanel>
</apex:page>

Apex class :

public String tabOpt {get;set;}

public void switch() {
  tabOpt = 'two';
} 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .