I have two tabs and a jquery function to handle it as shown below
<ul class="tabs">
<li id="tabBuy1" runat="server"><a href="#tab1">For Buy</a></li>
<li id="tabSale1" runat="server"><a href="#tab2">For Sale</a></li>
</ul>
<script type="text/javascript">
$(document).ready(function () {
//When page loads...
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tabs li").click(function () {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active ID content
return false;
});
});
</script>
I have type in session variable .
I want if type is 1 the buy is selected else sale tab is selected
Maybe the mistake is in the counter. I'm pretty sure that in this cases the counter starts in 0. Maybe is for that reason you get selected one tab but not the one that you want.
animesh.andy
Member
119 Points
243 Posts
Jquery Tabs
Mar 30, 2012 08:59 AM|LINK
I have two tabs and a jquery function to handle it as shown below
<ul class="tabs"> <li id="tabBuy1" runat="server"><a href="#tab1">For Buy</a></li> <li id="tabSale1" runat="server"><a href="#tab2">For Sale</a></li> </ul> <script type="text/javascript"> $(document).ready(function () { //When page loads... $(".tab_content").hide(); //Hide all content $("ul.tabs li:first").addClass("active").show(); //Activate first tab $(".tab_content:first").show(); //Show first tab content //On Click Event $("ul.tabs li").click(function () { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); }); </script>I have type in session variable .
I want if type is 1 the buy is selected else sale tab is selected
How to to it
avinash_rc
Participant
1020 Points
231 Posts
Re: Jquery Tabs
Mar 30, 2012 09:35 AM|LINK
I am not sure about above code but try adding default CSS styles for jquery tabs.
check example: http://www.codegateway.com/2012/02/jquery-tabs-ui.html
code samples
--------------------------------------------------
ramiramilu
All-Star
95473 Points
14106 Posts
Re: Jquery Tabs
Mar 30, 2012 09:54 AM|LINK
Access C# variables in javascript/jquery - http://www.intstrings.com/ramivemula/articles/access-code-behind-variables-in-aspx-and-javascript/
using that you can get to know session string in clientside, then you can set focus for jquery tab....
Thanks,
JumpStart
Oscar Gomez
Member
40 Points
21 Posts
Re: Jquery Tabs
Mar 31, 2012 01:58 PM|LINK
Hi,
Maybe the mistake is in the counter. I'm pretty sure that in this cases the counter starts in 0. Maybe is for that reason you get selected one tab but not the one that you want.
Regards,
__________________________________
Oscar Gómez
Engineer at PSL
http://www.pslcorp.com/
asteranup
All-Star
30184 Points
4906 Posts
Re: Jquery Tabs
Apr 02, 2012 10:15 AM|LINK
Hi,
You can save your selection in a hidden field and resigne once reloaded-
http://www.delicious.com/anupdg/tabs+selectedindex
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog