ny su ny su - 1 year ago 59
jQuery Question

get active tab name into a hidden field at runtime

I have aspx page with tabs like below...

<ul class="tabs-menu" style="list-style-type: none;" >
<li class="active"><a class="anchor" href="#ATab" style="text-decoration: none;" > A</a></li>
<li><a class="anchor" href="#BTab" style="text-decoration: none;">B</a></li>
<li><a class="anchor" href="#CTab" style="text-decoration:none;">C</a></li>


This is the hidden field that should store the active tab and pass it to a function when clicked on submit button on Modal popup

<input type="hidden" name="findTab" id="findTabname" value=""/>

I am showing this ASPX page as Modal pop up from another page using Jquery like below

$("#Test").live('click', function OpenSearchDialog() {
$("#dialog_testsearch").load("Test.aspx", function() {
autoOpen: true,
modal: true,
width: 750,
buttons: {
Go: function() {
var current_tab = $("#anchor").tabs('option', 'selected');
//anchor is my class for the list items

Close: function() {
$(this).container.css('height', 'auto');
return false;

Now My question is how do I get the name of active name into that hidden field ? And then into this Jquery when clicked on Go button..
Because I wanted to execute functions based on tabs selected

function callTestFunction()
if A
//do this
if B
//do this
if c
//do this

I am really hitting my head to the wall to this simple thing. But I couldn't get it working

Prs Prs

Try it..

$('button').on('click', function(){
   $('#findTabname').val($('.tabs-menu li').index('.active'));

And when you want to use the value of the hidden input to active tabs back use..

$('.nav-tabs li:eq($('#findTabname').val()) a').tab('show');