0

Here what am trying to do is I created a unorderlist of 4 links. Link1 , link2 , link3 and link4. I created a new page for the unorderlist so that i can include it with php with include_once code in the main page. Actually what i want is when ever i clik any link its color be change but the remaining be unchanged. For eg. I click link1 . The page opens and remaining link color same as what i expected but when i click another link as link2 my previous link1 color and link2 color are same. I can't give a active class in each link because i include the unoderlist link in external page and include it with php include_once text. Any idea how can i complete it :(

Edited by brainfo: n/a

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by Dandello
0

You can create an active class, it makes no difference if your list is held in an external file that you include into the main page.

0

active class in each link and in same page..can you show me how ?

Edited by brainfo: n/a

0

I'm not sure I'm understanding the problem but what I THINK you're saying is you want the link that belongs to the page you're on to look the same as your active class but the other links to remain looking like the default.

For that, in your include use if/else

if ($var == 'x'){
	print ("<li class='a-nava'><a href='index.php'>Home Page</a></li>\n");
	}
else {print ("<li><a href='index.php'>Home Page</a></li>\n");
	}
if ($var == 'a'){
	print ("<li class='a-nava'><a href='about.php'>About Us</a></li>\n");
	}
else {print ("<li><a href='about.php'>About Us</a></li>\n");
	}

where 'a-nava' has the same styling as your 'a:active'.

On each page, above the include:

<?php 
	$var = 'x';
	?>

Each page gets its own identifier code in $var.

I'm sure there are other ways of doing this, but this one works for me.

0

I cant judge anybody code but in my sense its little long. Is there any other process to do it easily.. Watch www.w3schools.com chek this site in left buttons so easily it manage. when ever i click any link it becomes bold remaing all unchanged and again when ever i click other link it becomes bold and remaing others become unchange with same color..

0

They're using asp - which means the code that's being served was generated server-side, probably by a similar if/else system that I showed you.

You can probably do it in javascript as well, but you still have to have a way of linking the link to the page and changing the styling based on that.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.