473,569 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change link color when click

250 Contributor
In my php web site I have left pannel which is having links to all pages. I want to change link color or background color when clicked. How can I do that? This is my current code. Could someone help me?
Expand|Select|Wrap|Line Numbers
  1. $array1 = array("A"=>'A.php',"B"=>'B.php', "C"=>'C,"D"=>'D.php',"E"=>'E.php',"F"=>'F.php');
  2. $arraypre = array();    
  3.  
  4.                         switch ($type){
  5.                         case "User1":$arraypre = array('G'=>'G.php','H'=>"H.php",'I'=>"I.php");break;
  6.                         case "User2"            :$arraypre = array('G'=>'G.php');break;
  7.                         case "User3"        :$arraypre = array('G'=>'G.php');break;
  8.                         }
  9.  
  10.         $array = array_merge($arraypre, $array1 );
  11.  
Feb 20 '09 #1
2 3989
TheServant
1,168 Recognized Expert Top Contributor
You can use javascript or the a:active class in css.

PHP will not help because PHP is server side, so once the page has been sent to the browser (and the user can see it) it is out of PHP's hands and into the realm of javascript and html.
Feb 20 '09 #2
tharden3
916 Contributor
Unless you want to use Javascript, the CSS method is pretty easy to do. Look here if you need further explanation on using CSS to manipulate links. As suggested by TheServant in the post above, your looking at using the " a:active " property.
Feb 20 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1641
by: Danny | last post by:
Hello I am looking for an asp change password solution. I know there are very efficient ways of doing it and perhaps you have some samples or ideas. Basically I would like the user to be able to change their password. Then a link is mailed to their email address on file and when they click on the link, they are taken to a place to type in...
3
17073
by: Matt Adams | last post by:
As well known I could specify the text color in the body tag like: <BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE> What I want to achieve now is that always (!) the text of the last visited link and the text of the link under the cursor are red. All other links should be white. The problem with the construction above is that a visited...
5
35214
by: Matt | last post by:
I created 3 hyperlinks, when the user click each link, it will change the color of the text of a link. For example, when user clicks Link1, text Link1 will become red color, but Link2 and Link3 unchange. Here's my attempts, any ideas?? <script language="javascript"> function changecolor (i) { document.i.fontcolor = red; }
7
19276
by: Mike Mimic | last post by:
Hi! I am trying to implement link click counter so that user can still bookmark the link (I rather see that click is not counted than user have "problems"). <a href="http://www.google.com/" onClick="JavaScript:document.location.replace('http://www.mypage.com /cgi-bin/count?http://www.google.com/'); return false;">Google</a>
2
9526
by: Ben | last post by:
Hi. I have a button that change a number of images src's when I click a button. The src's are stored in an array and I just use document.src=pics to change the src of the image. However I want the button to change the link as well to the image that is displayed but i cannot get it to work. How do I do this. Could someone tell me or point...
11
19581
by: Yeah | last post by:
I have a multiple choice quiz where I would like to use CSS to change the color of the answers upon clicking them. I would like to present the right and wrong answers up front, rather than direct the user to a separate page with all correct answers. Do the answers have to be "links" for this to work? They have to be inactive links, because...
6
3180
by: Karl | last post by:
Hi, Ok so on a given page I have 4 text links: see it in black see it in blue see it in red see it in green using the standard swap image behavior, clicking on one of the above links
2
1744
by: rich | last post by:
I am working on a page with a right column that I want to use for navigation. In this right column I am using the below code to set a value for the link. I am using the variable $test right now. I want to click on the link and when the value is set to a certain value, say 1, I want the script to run and load a page based on a switch case. ...
5
6835
by: james.calhoun | last post by:
I feel like this should be really easy... I want a hidden field in a form to have its value defined when someone clicks on a link. So if they click on link "A" the value of the hidden field becomes "A", while if they click "B" the value of hidden field becomes "B" Help?
22
4678
by: subashinicse | last post by:
hi to everybody, am new to this forum.. am working with J2ee,i have a jsp page where i have some links,i want to change the link color when it is active,and it has to turn back to original color when the other link is active, i tried with style sheets,when i click on the link its changing its color,but when the form loads ,its turning back...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.