The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

Need help targeting a tab

I have a site that uses nested tabs. From time to time, I need to load a page so that it opens with a tab other than the first one on top. For example, on this page, click on the Add Clients button (the "+" icon after the word "Clients"). It naturally opens with the Demographics tab on top, but what if I wanted to open it with the Insurance tab on top?

This looks right but I'm having trouble seeing exactly how to implement it because of the way my files are set up. popups.php doesn't use the javascript:newWin thing to call this particular page because it happens on a form submission.

I tried it that way and it didn't work. I also tried putting the getElementById part in with the first switch statement, but it still didn't do anything. Could the problem be with the function call? I tried it this way but somehow it doesn't look right:

PHP Code:

g_goto("popups.php?popupContent=addClient&openTab=insur");

I'm wondering if we need to use popups.php to set a variable - like maybe:

Why not? In first Switch it's looking for a match. When finds it, it goes out of switch block(break) and continue to second Switch...
This is a simplified version of your problem:
On first page you have a link(in your case a + sign):

Code HTML4Strict:

<ahref='second_page.php?a=1&b=2'>+</a>

which will open a popup window with desired tab opened.
I'm sending 2 parameters a=1 and b=2 to page 'second_page.php'.
On 'second_page.php' I have this code:

I'm testing arrived parameters. First Switch finds match and include a page 'mytabs.php' to current page (second_page.php). After that we're testing second Switch and also find match which is executing a JS code. This code finds tag with an id 'test' and fire onclick() on it.
Page 'mytabs.php' has this code:

Code HTML4Strict:

<ahref='#'id='test'onclick="alert('tab changed')">TABS</a>

It just alerts a message. In your case it will change to desired tab.
Hope this will help....

This is helpful. I'm really learning a lot, which I like. I still can't get it to work, though. I tried simplifying it by removing the function and just going straight from the page with the "+" on it, like in your example.

Did you tried ti debug it somehow? Try to make sure that parameter openTab came to popups.php. Use somewhere on popups.php echo $_GET['openTab'] to see if it's there. Can you download attachment?

Yes, it's getting to both popupContent and openTab, so that part's working. I got your attachment earlier this morning and have been playing with it. I added the scripts for my tabs in case that's what's messing things up. It does trigger the alert, but doesn't actually fire the tab even after you dismiss the alert. Are we missing something to tell it to actually open the second tab once it finds it?

I've attached what you sent me with the extra js scripts and the styles so you can see what's happening. I really do appreciate the help. This is beyond me.