JavaScript & CSS Tab issue on PHP site


I am implementing the following CSS tab system:

However, I would like to use a URL variable to change the tab that should be displayed on page reload.


Would default to the 2nd tab being open rather than the first.

The site is running with PHP as well, though I would prefer a pure JavaScript option (and my skills are really rusty).

I have tried to get in touch with the Author but they are not responding.

Thanks in advance.
Who is Participating?
stirlingitAuthor Commented:
Hmm, thanks for you help but I managed to tap a friend to re-write the JS directly.
Julian HansenCommented:
You should be able to just put the <a> inside the <li> elements and then add onclick="return false;" to the link.

The event should bubble up and the tabs should behave as expected but on the outside it looks like you are clicking the link.
stirlingitAuthor Commented:
That sounds like a possible solution but if the tabs are only on a single page, say three forms that on single page (forms.php) then how would that work?

As ideally, I would like to use form.php?tab=3 if the user then submits form three.
Julian HansenCommented:
When you submit a form the button submits to the url of the parent form.
stirlingitAuthor Commented:
Managed to get a friend to re-write the main code that meant that I only needed to add URL hash tags rather that adding additional script to the main page.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.