2

First of all, excuse my 'Tarzan' english... I have a tipical JQuery tab's code like that:

<div id="tabs">
    <ul>
        <li><a href="#tabs-1">One</a></li>
        <li><a href="#tabs-2">Two</a></li>
        <li><a href="#tabs-3">Three</a></li>
    </ul>
</div>

And I have three forms inside each tab something like that:

<div id="tabs-1">
    <form id="alpha">
        ...
        <input type="submit" value="send"/>
    </form>
</div>
<div id="tabs-2">
    <form id="beta">
        ...
        <input type="submit" value="send"/>
    </form>
</div>
<div id="tabs-3">
    <form id="gamma">
        ...
        <input type="submit" value="send"/>
    </form>
</div>

After doing a submit, page reloads and it changes to the very first tab (#tabs-1). My question is: How do I do to restart my page in a desired tab after submitting any form? For example, if I submit the "gamma" form, I want the page to reload in #tabs-3.

Can I do it?

Thanks in advance!

aNGRoN
  • 63
  • 5
  • this question has been asked before: http://stackoverflow.com/questions/4565128/set-default-tab-in-jquery-ui-tabs – esviko Feb 14 '14 at 10:22

2 Answers2

2
$(document).ready(function () {
    $([tab container]).tabs( "option", "active", [tab number] );
});
AfromanJ
  • 3,922
  • 3
  • 17
  • 33
RobinvdA
  • 1,313
  • 2
  • 13
  • 28
  • I'll work on your solution by now, until somthing better comes ;). Can you explain me how to adapt it? I think I should add these as a function, didn't I ? – aNGRoN Feb 14 '14 at 12:07
  • I'm trying to 'clean' it, because of the server-side language of our own... But basically the neat code is in the answer. Should I adapt function for the onClick event on the submitter buttons? Sorry, I'm teacher, and I have been outside coding for several years until now... I'm not a newbie, but an amnesic programmer. ThanksALot – aNGRoN Feb 14 '14 at 13:32
  • After the submit, when the page loads, is it possible for you to use the serverside language to check which form was submitted? And also can your serverside language print anything on the page? If so, you should check what form was submitted and print the lines from my answer on the page with the right tab number. – RobinvdA Feb 14 '14 at 13:38
  • No, RobinvdA, my server side language is very poor. We use it only to 'cap' PHP unsafe functions & procs. It can only be cheched to know very little things (userId, etc). We have also some session variables & cookies, but they are untouchable due to the system-architecture. – aNGRoN Feb 17 '14 at 12:20
  • Can you put PHP in your page? Without something like PHP i think it's going to be pretty hard to achieve your goal. Maybe you can read the answer to this question http://stackoverflow.com/questions/439463/how-to-get-get-and-post-variables-with-jquery Looks like he was trying to do the same as you – RobinvdA Feb 17 '14 at 12:42
  • Thank you Robin. PHP could be added to my code, but if I can do it without PHP, it will be better for us. Our core developers hate PHP. That's why they have created eBDML, our server-side language. The answer you propose is neat and better, but THEY (bosses) don't want PHP code in our pages... DAMN! – aNGRoN Feb 17 '14 at 12:51
0

Use cookie to remember form selection upon submit and on page load, check last selection and activate the last selected form accordingly

rt2800
  • 3,045
  • 2
  • 19
  • 26
  • sorry, I can't use cookies... we have a own parsed-server-language (eBDML) that does all session & cookies management. – aNGRoN Feb 14 '14 at 10:25