473,890 Members | 1,773 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();    
  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.                         }
  10.         $array = array_merge($arraypre, $array1 );
Feb 20 '09 #1
2 4003
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
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

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 a new password. Thanks in advance
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 link remains for the rest of the session red regardless wether it was visited 17 clicks back in...
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; }
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>
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 me in the direction of some code that will do this. I would like to do it in a similar way to...
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 they don't actually go anywhere. They only serve the purpose of changing color whether they're...
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
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. This way I can use different links for navigation that will load different forms and areas of my...
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?
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 to the original color,i want the color to stay even after the form loads. can anybody help me...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.