Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3677996
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:17:19+00:00 2026-05-19T03:17:19+00:00

I need to know how to link (via a regular href anchor on a

  • 0

I need to know how to link (via a regular href anchor on a different page) to content that is inside a tab that is not the default tab. Can this be done? My code will explain hopefully what I require:

My Code:

The following is my profile_edit.php page:

The javascript:

<script src="Javascript/jquery-1.4.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
 $(function () {
 var tabContainers = $('div.tabs > div');
 tabContainers.hide().filter(':first').show();

 $('div.tabs ul.tabNavigation a').click(function () {
   tabContainers.hide();
   tabContainers.filter(this.hash).show();
   $('div.tabs ul.tabNavigation a').removeClass('selected');
   $(this).addClass('selected');
   return false;
 }).filter(':first').click();
 }); 
 $(function () {
    var tabs = [];
    var tabContainers = [];
    $('ul.tabs a').each(function () {
      // note that this only compares the pathname, not the entire url
      // which actually may be required for a more terse solution.
        if (this.pathname == window.location.pathname) {
            tabs.push(this);
            tabContainers.push($(this.hash).get(0));
        }
    });

    // sniff for hash in url, and create filter search 
    var selected = window.location.hash ? '[hash=' + window.location.hash + ']' : ':first'; 

    $(tabs).click(function () {
        // hide all tabs
        $(tabContainers).hide().filter(this.hash).show();

        // set up the selected class
        $(tabs).removeClass('selected');
        $(this).addClass('selected');

        return false;
    }).filter(selected).click();
});
</script>

The html and PHP (a portion):

<div class="tabs">
  <ul class="tabNavigation">
     <li><a href="#account_div">Account</a></li>
     <li><a href="#change_password_div">Password</a></li>
     <li><a href="#favorites_div">Favorites</a></li>
     <li><a href="#avatar_div">Avatar</a></li>
  </ul> 
  <div id="account_div">
     <?php include("personal_info_edit.php"); ?> 
     </div>
     <div id="change_password_div">
     <?php include("change_password.php"); ?> 
     </div>
     <div id="favorites_div">
     <?php include("favorites.php"); ?> 
     </div> 
     <div id="avatar_div">
     <?php include("avatar.php"); ?> 
     </div>
   </div>

The following is contained in my change_password_submit.php page:

$update_pass= ("Password changed successfully.");
header("location:profile_edit.php?update_pass=$update_pass#change_password_div"); 
exit();

By default, whenever profile_edit.php is loaded, the personal_info_edit div is shown and the others are hidden. What do I need to change in the code so that I can reference the 2nd div (ie. change_password div and hide the rest after someone changes their password?
Any help will be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:17:20+00:00Added an answer on May 19, 2026 at 3:17 am

    This is perhaps not the most elegant solution, but it should work.

    You can have PHP sniff your url variables for the existence of a particular variable. I’d probably call this something like ‘selectedTabId’ or something like that. Then, if that variable exists, you can have jQuery invoke the click action on that tab. You’ll want to use switch/case for this rather than just sending through whatever happens to be in the URL, as people can put nasty things there that you don’t want your jQuery to run. I won’t do that in my example below, for expediency’s sake.

    This is a notional example…

    <?php
    if( array_key_exists('selectedTabId',$_GET) ){
      $selectedTabId = $_GET['selectedTabId'];
      echo "<script type=\"text/javascript\">";
      echo "jQuery(document).ready(function(){'#$selectedTabId').click()});";
      echo "</script>";
    }
    ?>
    

    Give that a shot and see if it works for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to know how the performance of different XML tools (parsers, validators, XPath
I need to know how much space occupies all the databases inside an SQL
I need to send a signal via my remote PC to the Internet that
I need to know about Epoll On linux System. Could you recommend manual or
I need to know how to turn on Code Coverage when running TFS builds
I need to know when the memory will be allocated for a particular program.
I need to know, from within Powershell, if the current drive is a mapped
I need to know how I get the stream of the headers and footers
I need to know what internet connection is available when my application is running.
I need to know when the user finishes editing a cell in an NSTableView.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.