473,395 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

changing color of inactive menu links in a menu

pradeepjain
563 512MB
i have a menu of 4 items.all text color is white. and when i click a menu link the other menu items text color should change to black! Is it possible to do with css or javascript help is needed for this !if any example is there this would help me a lot as i am not gud in javascript!
May 16 '09 #1
4 7786
prabirchoudhury
162 100+
1. Its easy to use css and whenever you are in web development then good practice to use css

2. in the normal way only selected menue button get change .. then other that make sense to the user that this button has been selected.. but dont get other button color change.
3. i have given css code for that menu changes.. do other changes if you need ..


4. call the menu_text class frm the <span class=menu_text ><a > menu1</a> </span>
<span class=menu_text_selected ><a > selected menu</a> </span>

5. but you need to do little bit logical argument here. in the begaining of the page need to find what page is that being selected, have to pass a flag or page id frm the menu link selected. like

Expand|Select|Wrap|Line Numbers
  1.  
  2. <span <? if ($_GET['btn'] ==page1) { echo "class=menu_text_selected ";}else {echo "class=menu_text";}?>>
  3. <a href="page1.php?btn=page1> menu1 </a></span>
  4.  
  5. <span <? if ($_GET['btn'] ==page2) { echo "class=menu_text_selected ";}else {echo "class=menu_text";}?>>
  6. <a href="page1.php?btn=page2> menu2 </a></span> 
  7.  
  8.  

and so on for all the menus


Expand|Select|Wrap|Line Numbers
  1. css code ...
  2. .menu_text {
  3.  color : white;
  4.     text-decoration : none;
  5.     font-size : 11px;    
  6. }
  7. .menu_text A {
  8.     color : white;
  9.     text-decoration : none;
  10.         font-size : 11px;
  11.   }
  12.  
  13.   .menu_text A:HOVER {
  14.     text-decoration : underline;
  15.     color:#147404;
  16.     font-size : 11px;
  17.   }
  18.  .menu_text_selected {
  19.     color:black;
  20.     font-size : 11px;
  21.   }
  22. .menu_text_selected a {
  23.   font-weight: bold;
  24.   color:black;
  25.   font-size : 11px;
  26.   }
  27.  
  28. .menu_text_selected a:hover {
  29.   font-weight: bold;
  30.   color:black;
  31.   font-size : 11px;
  32.   }
  33.  
  34.  
May 17 '09 #2
pradeepjain
563 512MB
The way u said is okie but instead of using 2 span classes u can just use a:active which does the job for u.I have done this!!
The way i asked for is clients requirements ..any idea on how to get it done :)

@prabirchoudhury
May 18 '09 #3
Dormilich
8,658 Expert Mod 8TB
I see no other possibility than using Javascript. (although your Client's requirement really doesn't make much sense)

basicly you have to make all links black and then make the current link white again.

concept
Expand|Select|Wrap|Line Numbers
  1. links = document.getElementsByClassName("menu"); // the class refers to your links
  2.  
  3. foreach // this is not valid, but you know what I mean…
  4. {
  5.   link.addEventListener("click", makeBlack, false); // check out the workarounds for IE!
  6. }
  7.  
  8. function makeBlack()
  9. {
  10.   foreach // …
  11.   {
  12.     link.style.color = "black";
  13.   }
  14.   this.style.color = "white";
  15. }
May 18 '09 #4
prabirchoudhury
162 100+
that’s true.. it is not abt that he is client and paying for that and any how we do have to make for this .. follow the web standard also important..
May 18 '09 #5

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

Similar topics

1
by: Bizt | last post by:
Hi, I would like to create a menu where the menu options were taken from an XML file. The reason is that I would be able to update the xml file (by simply adding new child nodes) after I...
3
by: mvargasp | last post by:
Hi all, I have a web form which contains a frame, (a form containing a menu on the left and a web form containing a datagrid on the right). Also there is a button (right side) which transforms...
14
by: Don G | last post by:
Within the menu for my site, I have inserted 'class="current"' within the link for the current page. So the link looks somthing link: <li><a href="index.php" class="current">Home</a></li> The...
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
1
by: Henry Nelson | last post by:
Hi all I'm very new to dotNet and just trying to get my head around the right way to do the thing that I would normally do in asp. In asp I would loop through a recordset and output all the...
5
by: Cecilia Bergengruen | last post by:
2 questions: 1)I inserted a menu in an mdi window form. I right clicked on a menu item and pressed edit names. I therefore edited all my menu item names. Then I right clicked and pressed edit...
1
by: DJG79 | last post by:
Hi all, I am using an open source menu that i found and it works great, except for one thing that when the web page is not scrolled to the very top the drop down links will not stay visible. Has...
10
by: IloveTacos | last post by:
Hey, New to asp and I need some help. I created a jump menu that links to different portals. Each portal has all the same images/text, but I wanted to change all the links on each portal to...
3
pradeepjain
by: pradeepjain | last post by:
Hii guys, I have a menu with 5 links with default color as white(text).I have a small prob...Say when i click on a link, I have to change the color or other links to grey .Is that...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
tracyyun
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...

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.