![]() |
php tab select
Hey everyone, I have come to something I am working on for my website template. I have a top navigation that are tabs and when you click a tab to the next page it pops out the next tab as the selected tab. Very basic with HTML this is my sample code for it.
Code:
<ul>Quote:
|
so for example if I click portfolio. it would take me to porfolio.php but the portfolio tab in the nav would have the selected id? I might have understood wrong, but that is always a high possibility this early.
to keep it as you have it now. I would just use something like: PHP Code:
|
Here is my js solution.
HTML Code:
<ul id="tabs"> |
It's really not all that hard (at least compared to some things). There are a number of ways. One easy(?) way is to define a function that accepts an argument to indicate which one is selected:
PHP Code: function tabs($active) { $tabs = array( 'Home' => '/index.php', 'About Us' => '/about/index.php', 'Contact Us' => '/contact/index.php' ); echo "<ul id='tabs'>"; foreach($tabs as $label => $path) { if($label == $active) { echo "<li class='active'>$label</li>\n"; } else { echo "<li><a href='$path'>$label</a></li>\n"; } } echo "</ul>\n"; } Then in your pages: PHP Code: <html>...<body> <?php include $_SERVER['DOCUMENT_ROOT'].'/includes/functions.php'; tabs('Home'); ?> rest of page... |
| All times are GMT. The time now is 08:16 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0