Reputation: 941
<ul class="tabs" style="background: ">
<li><a href="javascript:tabSwitch('tab_1', 'content_1');" id="tab_1" class="active">Payment Gateway Basics</a></li>
<li><a href="javascript:tabSwitch('tab_4', 'content_4');" id="tab_4" >Contact Us</a></li>
</ul>
These are my tabs, once I submit a form in the "contact us" tab, it goes back to the first tab. Can anyone tell me how to stay in the same tab?
I'm using PHP server side switching, I'm using JavaScript.
(I used href
not onclick
in the listing. Stack Overflow doesn't allow to use more href
so I changed it into onclick
, before this post was edited).
Upvotes: 0
Views: 209
Reputation: 14447
You'll need some initialization script to determine what tab to activate when loading your page. The most common way is to add an anchor to your request url and read that using javascript. Evaluate that value to determine what tab to activate and do so with your javascript tabSwitch function.
This is a very simplistic example but illustrates the idea. This should be executed after domready.
var activeTab = self.document.location.hash;
if(activeTab !== ''){
switchTab(activeTab);
}
Upvotes: 0
Reputation: 7438
no directly provision
You have to pass some querystring
Read it on page_load in javascript
and set the tab from javascript based on the query string value.
Upvotes: 1