469,908 Members | 2,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,908 developers. It's quick & easy.

how to remain an a tab when button is clicked

123 100+
i have a CSS tab which is tab1 and tab2 and both are on the html page, in both tabs i have a submit button (<input type="submit" name="submit1"/>) on both. if i am in tab2 and i click submit i want it to remain in tab2 not to go back to tab1
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  <head>
  3. <title></title>
  4.  <link href="SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
  6. <script type="text/javascript" charset="utf-8"> 
  7. function show(div){
  8. document.getElementById(div).style.display='';
  9. }
  11. </script>
  12. </head>
  13. <body>
  14.  <?php
  15.  if (isset($_GET['page'])) {
  16.  $pages = ($_GET['page']);
  17.  } else {
  18.  echo "page one";
  19.  }
  20.  ?>
  22.  <ul class="TabbedPanelsTabGroup">
  23.  <li class="TabbedPanelsTab" tabindex="0"  id="one" >Tab1</li>
  24.  <li class="TabbedPanelsTab" tabindex="0"  id="two" >Tab2</li>
  25.  </ul>
  27.  <div class="TabbedPanelsContent">
  28.  <div>
  29. <form action="home.html" method="post">
  30.   <input type="submit" name="submit1"  value="Submit"   onclick="show('one')"/>
  31. </form>
  32.  </div></div>
  34.  <div class="TabbedPanelsContent">
  35.  <div>
  36. <form action="home.html" method="post">
  37.   <input type="submit" name="submit1"  value="Submit"   onclick="show('two')"/>
  38. </form>
  40.  </div></div>
  42.  </body>
  43.  </html>
Aug 23 '10 #1
7 3543
5,390 Expert Mod 4TB
then you could either use AJAX-calls to avoid the page-reload or add a flag serverside to the page (could be a javascript-variable like: var startTab = 'tab2') and process it in the page's onload event.
Aug 24 '10 #2
638 512MB
or you can do the same but submit the values on a separate page and then return back to this page with a query string which could be checked to make any of those tab selected
lets say form is submitted on the page2.php after doing your operations

and on the orignal-page.php check
if(isset($_GET['tab']) && $_GET['tab']==1){
//make your tab selected by either applying the css class or what ever you desire

Omer Aslam
Aug 24 '10 #3
123 100+
i want it on the same page(home.php) but the tab2 which i am on and i click on submit inside tab2 on the samepage(home.php) don't forget should display the tab2 i am on and not to take me but to tab1
Aug 24 '10 #4
638 512MB
if you mean to say that you donot want to submit it on another page then it would be better to use AJAX other wise if the requirement is that after submitting the information you want to be back on the same tab then i have told you the solution it would work in the same way
Aug 25 '10 #5
123 100+
i am a newbie when it come to Ajax but if you say it is going to work the same way i need you to edit my code and let me see it
Aug 30 '10 #6
123 100+
This is what am trying to say, the tabs are on the same page not different pages am talking about the content of the tabs i want the content of tab2 to display when ever i click submit button(onclick)in the content of tab2 not to take me back to tab1.
Oct 15 '10 #7
123 100+
please am still waiting for my reply
Oct 23 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by TJS | last post: by
5 posts views Thread by Jim in Arizona | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.