Solved

JavaScript & CSS Tab issue on PHP site

Posted on 2013-06-12
5
448 Views
Last Modified: 2013-06-18
Hello,

I am implementing the following CSS tab system:

http://www.my-html-codes.com/javascript-tabs-html-5-css3

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

i.e. http://www.testsite.com/?tab=2

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.
0
Comment
Question by:stirlingit
  • 3
  • 2
5 Comments
 
LVL 52

Assisted Solution

by:Julian Hansen
Julian Hansen earned 100 total points
ID: 39240575
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.
0
 

Author Comment

by:stirlingit
ID: 39240863
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.
0
 
LVL 52

Assisted Solution

by:Julian Hansen
Julian Hansen earned 100 total points
ID: 39241114
When you submit a form the button submits to the url of the parent form.
0
 

Accepted Solution

by:
stirlingit earned 0 total points
ID: 39243856
Hmm, thanks for you help but I managed to tap a friend to re-write the JS directly.
d-tabs.js
0
 

Author Closing Comment

by:stirlingit
ID: 39255579
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now