473,781 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Keeping buttons stay a different colour after being selected

Hi there, this'll be an easy one I'm sure. I have a small question that will
take a second to answer, I am sure.

If you go to
http://snipurl.com/t821
All the buttons on the left are red, and when the mouse hovers over them,
they go green.

How do I make it so that the buttons stay on green (or indeed any other
colour) after being selected? So that the visitor knows which page he or she
is on?

(OH ignore the layout of the actual site... I know it's in yucky tables at
the moment, but all the sections will be copied and pasted into CSS includes
etc next week, and the site will look much more professional).

Each "cell" in the menu is like this:

<!-- Begin Cell 1 -->

<td nowrap="nowrap" bgcolor="#ff000 0"
onmouseover="th is.style.backgr ound='#00ff00'; this.style.colo r='#000000'"
onmouseout="thi s.style.backgro und='#ff0000'; this.style.colo r=''"
style="font-weight: bold; color: ; font-family: Arial,sans-serif;font-size:
14pt; text-align: center;cursor: hand;" height="15"
onclick="window .location.href= 'http://www.cardaid.co. uk/catalog/includes/lan
guages/english/ecardsite/ecarddefault.ht ml';" title="ABOUT">A BOUT</td>

<!-- End Cell 1 -->
I am assuming that there is another onmouse event handler I can set for
this quite common requirement, but I can't for the life of me think of it.
Jul 21 '06 #1
7 2841
Hmmm, come to think of it, perhaps I should just add
this.style.back ground='#00ff00 '; this.style.colo r='#000000'
to the onclick? As in

<td nowrap="nowrap" bgcolor="#ff000 0"
onmouseover="th is.style.backgr ound='#00ff00'; this.style.colo r='#000000'"
onmouseout="thi s.style.backgro und='#ff0000'; this.style.colo r=''"
style="font-weight: bold; color: ; font-family: Arial,sans-serif;font-size:
14pt; text-align: center;cursor: hand;" height="15"
onclick="window .location.href= 'http://www.cardaid.co. uk/catalog/includes/lan
guages/english/ecardsite/ecarddefault.ht ml';
this.style.back ground='#00ff00 '; this.style.colo r='#000000';"
title="ABOUT">A BOUT</td>
But there again, even when it's in a CSS, how will the *next* page that
reopens, ie ecarddefault.ht ml, know what the previous onclick is? Since the
column with the menu will be "included" again, ie a new include, not the
same one.

(with frames, yes, I could make the colour stay green on onclick because the
frame would be static, it wouldn't be reloaded, the new stuff would simply
be loaded into the other frame. But with CSS it's not going to be the case,
is it?

Jul 21 '06 #2

Tristán White wrote:
But there again, even when it's in a CSS, how will the *next* page that
reopens, ie ecarddefault.ht ml, know what the previous onclick is? Since the
column with the menu will be "included" again, ie a new include, not the
same one.

(with frames, yes, I could make the colour stay green on onclick because the
frame would be static, it wouldn't be reloaded, the new stuff would simply
be loaded into the other frame. But with CSS it's not going to be the case,
is it?
Obviously, as you already know, as soon as you navigate to the next
page, all your css tricks will be useless as css can't be used for
persistence. There are a couple of solutions that are known that I can
think of right now to keep a menu persistent.

1. Frames
As you've already guessed.

2. IFrames
....

3. Create multiple files for each menu item.
This implies that you create a page for which the menu item is red and
a page for a situation when it is green. Obviously, maintenance will
easily become chaotic. (don't recommend)

4. Use cookies.
If you use javascript to manage your cookies, then obviously a downside
to it is that it won't work if your users have javascript turned off or
don't accept cookies. If you were to use cookies, a server-side
solution would be a better approach.

5a. Place all content into one page.
You use javascript to hide and unhide content depending on the menu
item selected. The downside of this is if the users have javascript
turned off, they see all the content. Also, your page size will be
big. (don't recommend)

5b. AJAX.
This is a derivative of the above. Instead of placing all content into
one page, you'll retrieve only the content that you need. Again,
you'll need to think of what happens if javascript is turned off.

There are probably other methods, but I cannot think of anymore. Hope
this helps you to innovate different ideas.

Jul 21 '06 #3
Tristán White wrote:
Hi there, this'll be an easy one I'm sure. I have a small question that will
take a second to answer, I am sure.

If you go to
http://snipurl.com/t821
All the buttons on the left are red, and when the mouse hovers over them,
they go green.

How do I make it so that the buttons stay on green (or indeed any other
colour) after being selected? So that the visitor knows which page he or she
is on?

(OH ignore the layout of the actual site... I know it's in yucky tables at
the moment, but all the sections will be copied and pasted into CSS includes
etc next week, and the site will look much more professional).

Each "cell" in the menu is like this:

<!-- Begin Cell 1 -->

<td nowrap="nowrap" bgcolor="#ff000 0"
onmouseover="th is.style.backgr ound='#00ff00'; this.style.colo r='#000000'"
onmouseout="thi s.style.backgro und='#ff0000'; this.style.colo r=''"
style="font-weight: bold; color: ; font-family: Arial,sans-serif;font-size:
14pt; text-align: center;cursor: hand;" height="15"
onclick="window .location.href= 'http://www.cardaid.co. uk/catalog/includes/lan
guages/english/ecardsite/ecarddefault.ht ml';" title="ABOUT">A BOUT</td>

<!-- End Cell 1 -->
I am assuming that there is another onmouse event handler I can set for
this quite common requirement, but I can't for the life of me think of it.

Why not just use regular HTML links (<a href="..">) for your menu items,
and use CSS on the a:visited pseudoelement to make them have a different
background color?
Jul 21 '06 #4
Why not just use regular HTML links (<a href="..">) for your menu items,
and use CSS on the a:visited pseudoelement to make them have a different
background color?

Because then if people visit more than two pages on the site - as I hope
they will - they will get very confused as there will be more than one page
with different background colours.
Jul 24 '06 #5
Thanks for your considered reply. The problem is going to be what happens
when Javascript/cookies are turned off, and as you say, multiple files will
make site maintenance a major PITA!

I might do a look into our stats to find out whether there is a graphic
showing how many of our visitors have cookies turned off.... If it's
miniscule, this may be the way forward. But somehow I think, in this day and
age of adware and whatnot, quite a lot of people have these things disabled.

I can't believe the much maligned frames are the best way of rendering this
properly!! I must find another solution. I'll have a browse around other
websites to see how they do it.

I guess one thing I could do would be to include instead an arrow in the
main part of the document (post CSS implementation) pointing to the relevant
part of the menu on the left hand side.

However, the two 'columns' don't always align in the same way depending on
the browsers. I've tried Firefox, Safari and IE and on all of them there is
a milimetre or two difference, depending also on screen size settings etc.
So this may be more trouble than it's worth. But at least, if I could
somehow fix it so that the two columns would ALWAYS be aligned equally no
matter what browser or screensize, then it could be a solution.

Jul 24 '06 #6

Tristán White wrote:
I can't believe the much maligned frames are the best way of rendering this
properly!! I must find another solution. I'll have a browse around other
websites to see how they do it.
Personally, I love frames for this purpose. They're the easiest way to
keep context between pages. Okay, but without them... let's see...
But there again, even when it's in a CSS, how will the *next* page that
reopens, ie ecarddefault.ht ml, know what the previous onclick is? Since the
column with the menu will be "included" again, ie a new include, not the
same one.
Hmm... the sheer fact that each button calls a specific page, means
that page knows which button to highlight, doesn't it?

Confused, Kev

Jul 24 '06 #7
Tristán White wrote:
>Why not just use regular HTML links (<a href="..">) for your menu items,
and use CSS on the a:visited pseudoelement to make them have a different
background color?


Because then if people visit more than two pages on the site - as I hope
they will - they will get very confused as there will be more than one page
with different background colours.

I apologize; I was confused about what you wanted.

First of all, you should still be using HTML links here instead of using
javascript. If you need the links to have a set width and height, you
can use CSS to accomplish this. Using javascript as your only means of
navigation is a bad idea.

Next, when you have links instead of just table cells, you can iterate
through them and compare their href to document.locati on using some
comparison scheme to determine which of the linked pages you are
currently on. Then, you can either alter that link's CSS class, or
modify its background-color (the former is a better way).

Jeremy
Jul 24 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3611
by: Ken Fine | last post by:
I've made a content managment system that uses icons to represent page layouts. To choose a different layout, the user clicks on a radio button associated with each layout icon. On click of one of the radio buttons, the form submits and a new layout is chosen. I would prefer if people can click on the icons themselves , rather than using the radio buttons.The border or background associated with the selected icon can highlight...
179
44453
by: SoloCDM | last post by:
How do I keep my entire web page at a fixed width? ********************************************************************* Signed, SoloCDM
4
2312
by: jake | last post by:
Maybe some kind person can help with a suggestion or two ;-) I want to construct a banner on a number of pages in the format: LHS: Text (variable content) RHS. Logo ..... each with a different background colour. The following test page shows what I'm trying to achieve (borders put in for diagnostic purposes).
5
5359
by: Axel | last post by:
An Access 2000 question Hi is is possible to have (as a subform) a continous form with 0..n buttons which have different images in each row. (Personally I would have preferred a button array and assign images in code, much easier with a class module - but unfortunately Access does not support control arrays).
2
1804
by: Carl Gilbert | last post by:
Hi I am looking to edit an icon at runtime on menu items such as change fill colour. I wish to replicate the features found in most applications where by the coloured bar on a colour picker icon changes colour to the last selected colour. Therefore the user can easily tell which colour will be apllied when
13
1588
by: Flashster | last post by:
I want to create buttons in the shape of bitmaps - i.e. without a square around them. How would I do this? Thanks, Flash
0
1288
by: vova12 | last post by:
Hello, I am trying to use group of four asp.net radio buttons and reset the checked value to true for the first radio button in the group, setting the Radiobutton1.Checked = True. But it not seems to work by some reason. When some button on the form(button "Clear")clicked, the selected radiobutton (RadioButton1.Checked=True) should be selected, but instead, the previously selected radiobutton stay selected,not to the first.
9
2060
by: Chris Saunders | last post by:
This is not actually a C# question but I'm not sure which newsgroup is appropriate for this question. My apologies if I'm being "off-topic". I'm writing and application that has a group box that contains a bunch of radio buttons and wish to keep this group box and its buttons centered when the width of the window is changed. I do know how to accomplish this using code but I wonder if there is a
6
5555
by: Brandon McCombs | last post by:
Hello, I have a form that contains a listview on the left side and a column of buttons on the right side. Only some of the buttons do I want enabled all the time. The other buttons should be enabled only if something is selected in the listview. That part specifically works but not very well. It seems that I can only get the buttons to disable if I click off the text of the items in the listview but still within about 10-20 pixels of...
0
9639
marktang
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...
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10076
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,...
0
9939
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 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...
1
7486
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6729
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();...
0
5375
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4040
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
2
3633
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.