title: JavaScript show last tab
body: <p>Okay so I've created 4 tabs and only 1 is shown at a time, but if I post something in a form in tab 4 then tab 1 becomes active but I want it to automatically show the tab that the stuff was posted in. Sorry if bad description but here is my code:</p>
  
  <pre><code>&lt;script src="../js/jquery-1.8.2.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
  $(document).ready(function() {
  
      //Default Action
      $(".tab_content").hide(); //Hide all content
      $("ul.tabs li:first").addClass("active").show(); //Activate first tab
      $(".tab_content:first").show(); //Show first tab content
  
      //On Click Event
      $("ul.tabs li").click(function() {
          $("ul.tabs li").removeClass("active"); //Remove any "active" class
          $(this).addClass("active"); //Add "active" class to selected tab
          $(".tab_content").hide(); //Hide all tab content
          var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
          $(activeTab).fadeIn(); //Fade in the active content
          return false;
      });
  
  });
  &lt;/script&gt;
  
  
  &lt;center&gt;
    &lt;ul class="tabs"&gt;
      &lt;li&gt;&lt;a href="#tab1"&gt;Tab 1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#tab2"&gt;Tab 2&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#tab3"&gt;Tab 3&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#tab4"&gt;Tab 4&lt;/a&gt;&lt;/li&gt;
  
    &lt;/ul&gt;
    &lt;div class="tab_container"&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
      &lt;div id="tab1" class="tab_content"&gt;
  &lt;center&gt;&lt;h2&gt;Tab 1&lt;/h2&gt;&lt;/center&gt;
                  &lt;/div&gt;
                      &lt;div id="tab2" class="tab_content"&gt;
  &lt;center&gt;&lt;h2&gt;Tab 2&lt;/h2&gt;&lt;/center&gt;
                  &lt;/div&gt;
                      &lt;div id="tab3" class="tab_content"&gt;
  &lt;center&gt;&lt;h2&gt;Tab 3&lt;/h2&gt;&lt;/center&gt;
                  &lt;/div&gt;
                      &lt;div id="tab4" class="tab_content"&gt;
                      &lt;?php
                      $getmessage = $_POST["message"];
                      if($getmessage != null) {
                          echo"Thanks for posting the text!";
                      } ?&gt;
  &lt;center&gt;&lt;form method="post" name="form4"&gt;&lt;input type="text" id="form4" name="message" placeholder="Type a text here"&gt;&lt;br&gt;&lt;input type="submit" value="Post text"&gt;&lt;/form&gt;&lt;/center&gt;
                  &lt;/div&gt;
  &lt;/div&gt;&lt;/center&gt;
  &lt;/center&gt;
  </code></pre>
  
  <p>So when I submit the form in tab 4 I get to tab 1 and I manually have to go to tab 4 to see the message that my echo shows. I need it to automatic go to the tab where the form was submitted, but I don't know how to do this.</p>