Open specific jquery ui tab based on which the previous page is
<p>I have created a jquery ui tab and what I would like to do is when the page containing the jquery ui tab loads, specific tab will open depends on the previous page. So far, I have down the following:</p>

<p>PHP:</p>

<ol>
<li>obtain the previous page by using $_SERVER['HTTP_REFERER'];</li>
<li>determine which tab to open by using a "if" statement (assigning a tab_index variable);</li>
<li>assign "tab_index" to a hidden input value.</li>
</ol>

<p>Javascript:</p>

<ol>
<li>pick up the hidden input value and assign it to a js variable;</li>
<li>??</li>
</ol>

<p>Then I am not too sure how to do this make it work in $('#tabs').tabs({.... statement. Any idea of how to resolve this will be much appreciated. Many thanks.</p>

<pre><code>PHP:
$string = $_SERVER['HTTP_REFERER'];
$string = substr($string, -(strlen($string)-strrpos($string, '/')-1), strlen($string)-strrpos($string, '/'));
if ($string == "specific_page.php") {
    $tab_index = 2;
} else {
    $tab_index = 0;
}

HTML:
...
&lt;input id="hidden_input" type="hidden" value="&lt;?php echo $tab_index; ?&gt;" /&gt;

JS:
$(document).ready(function() {
var tab_index = $('#hidden_input').attr('value')
$('#tabs').tabs({ cache:false,
    ajaxOptions: {
        error: function(xhr, status, index, anchor) {
            $(anchor.hash).html("Couldn't load this tab. We'll try to fix this as soon as possible.");
        }
    },
    ...something here for tab selection?...
});
});
</code></pre>
