i want to display the content of a tab when a button is clicked in the content

Discussion in 'PHP' started by simon2x1, Nov 13, 2010.

  1. #1
    I have a page, home.php. On the page, I have CSS tabs tab1 and tab2. The tabs are on the same page not different pages. I want the content of tab2 to display whenever I click the submit button in the content of tab2, not take me back to tab1.

    
    <html>
        <head>
        <title>home</title>
        </head>
        <link href="SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
        <body>
        <ul class="TabbedPanelsTabGroup">
        <li class="TabbedPanelsTab" tabindex="0">Tab1</li>
        <li class="TabbedPanelsTab" tabindex="0">Tab2</li>
        </ul>
    
        <div class="TabbedPanelsContentGroup">
    
        <div class="TabbedPanelsContent">
        //this is where the content of the tab1 will be and i have another form in this content too
    
        </div>
    
        <div class="TabbedPanelsContent">
        //this is where the content of the tab2 will be
        <form action="home.php" method="post">
        <?php
        if (isset($_POST['submit'])) {
        if(empty($_POST['boded']){
        echo"Please do it again.";
        }else{
         $mgs = ($_POST['boded']);
         //then insert to my database   
        }
        ?>
        <textarea id="message" name="boded" rows="5" cols="40"></textarea>
        <input type="submit" name="submit" value="Submit" />
        //if i click this button(submit) in this content it should display tab2 content not tab1
        </form>
        </div>
    
        </div>
        </body>
    	</html>
    
    Code (markup):
     
    simon2x1, Nov 13, 2010 IP
  2. bencummins

    bencummins Peon

    Messages:
    55
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Store a hidden variable in the form... <input type="hidden" name="tabPage" value="2">.... then on the next page... you can do..

    <?PHP
      if ($_POST["tabPage"] == 2)
      {
        echo "tab page 2...";
      }
    
    ?>
    PHP:
     
    bencummins, Nov 14, 2010 IP
  3. KingOle

    KingOle Peon

    Messages:
    69
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Look into ajax if you want to do this without page reloading.
     
    KingOle, Nov 14, 2010 IP