Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    wac
    wac is offline
    Regular Coder wac's Avatar
    Join Date
    Sep 2002
    Location
    Cary, North Carolina, USA
    Posts
    359
    Thanks
    2
    Thanked 0 Times in 0 Posts

    programatically modify anchor

    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+
    Wayne Christian

  • #2
    Regular Coder COBOLdinosaur's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    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>
    100% standards compliant code is 100% correct 100% of the time.
    one of my toys from my repository and perhaps some help getting help

    Cd&


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •