...

View Full Version : Programmatically modify anchor



wac
10-10-2003, 06:36 PM
I have a popup with a list of anchors that function like a 'select'.
The anchor color changes via a.myclass:hover correctly. However, when an anchor is selected, I want to set the a.myclass:visited to match the hover values, so that it looks selected. When a different anchor is selected, I want to unset the previous anchors visited colors and set the current anchors visited colors. The reason I'm not using a 'select' is two fold.
1. The select that I need is a dropdown tree (with icons) like explorers address field.
2. A select shows ontop of other objects, like DIVs used in menus.

The anchor mechanism does exactly what I want, except I need to emulate the 'current selection' mechanism.

How do I do this in javascript? This must work for IE6+ and NS6+

COBOLdinosaur
10-11-2003, 11:46 PM
just set up another class and swap it.

a.Aselected:visited {color:white;background-color:navy}

Then
<script>
<!--
currselect=false;
function setsel(target)
{
if (currselect) document.getElementById(currselect).className='myclass';
document.getElementById(target)className='Aselected';
currselect=target;
}
-->

Assuming the the link is something like:

<a id="someid" href="blah.com" onClick="setsel(this.id)"> click </a>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum