title: Automatically change active tab?
body: <p>The following displays several tabs with UnitName labels. When an associated tab is clicked it causes a table associated with that tab to be displayed (javascript).</p>
  
  <p>How would I change this so a particular UnitName is treated as the active one and display the associated table automatically as opposed to have to click the desired UnitName tab first?</p>
  
  <pre><code>foreach($unit_list as $unit)
  {
  echo '&lt;li&gt;&lt;a href="#unit'.$j++.'" data-toggle="tab"&gt;'.$unit['UnitName'].'&lt;/a&gt;&lt;/li&gt;';
  }?&gt;
  
  //the following doesn't happen until the javascript knows which tab is active
  
   &lt;div class="tab-content"&gt;
   &lt;?php $j=0;$i=0;
       foreach($unit_list as $unit)
       {?&gt;
  
           &lt;div class="tab-pane" id="unit&lt;?php echo $j;?&gt;"&gt; 
           &lt;ul class="nav nav-tabs tab-color" id="deptTabs"&gt;
               &lt;?php $userDept = 0; $k=$i; foreach($dept_list[$j] as $dept)
               {?&gt;
                   &lt;li
                       &lt;?php
                       if($dept['Department']==$user_info[0]['Department'])
                       {
                           $userDept=$i;
                           echo "class=\"active\"";
                       }?&gt;
                   &gt;
                       &lt;a href="#dept
                       &lt;?php echo $i;?&gt;
                       " data-toggle="tab"&gt;
                   &lt;?php echo $dept['Description'];?&gt;&lt;/a&gt;&lt;/li&gt;
                   &lt;?php $i++;
               }
               $i=$k #put i back to the value it started at?&gt;
           &lt;/ul&gt;
  </code></pre>