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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts

    :: looking for an image toggle script.. ::

    i want a script that when user clicks on a text link the image beside it toggles between 2 images

    its basically for a tree menu system i got but for some reason everything i do refuses to work..

    here is what i have...

    ------------------------------------

    <table width="100%" border="0" cellspacing="0" cellpadding="1"><tr><td width="10" valign="top">


    <img src="http://www.simonsgroup.com/kamtoolbox/images/plusImage.gif" border="0" align="absmiddle" name="A4279028BD175F3380256DBB005182C7">


    </td><td class="mainsection" onMouseOut="tableOut(this)" onMouseOver="tableOver(this)">

    <a class="expandable" href="javascript:;" onClick="this.blur()"> Consultant contact</a><br>


    <p class="subsection" style="display:none">
    <img src="http://www.simonsgroup.com/kamtoolbox/images/linkImage.gif" border="0" align="absmiddle"><a href="http://www.simonsintranet.com" target="_blank"> How to contact </a><br>
    <img src="http://www.simonsgroup.com/kamtoolbox/images/docImage.gif" border="0" align="absmiddle"><a href="B5E9593546F2BE4C80256DBF003CF04E/$file/contract.pdf" target="_blank"> What to do after contact</a><br>
    </p></td></tr></table>

    ------------------------------------

    the bold bit is the link and the italic is the image that needs to be swapped

    image locations are:

    http://www.simonsgroup.com/kamtoolbo.../plusImage.gif
    and
    http://www.simonsgroup.com/kamtoolbo...minusImage.gif

    thx all

    i thought i could do a simple if image = minus swap to plus and if plus swap to minus but for some reason i cant get it working ...

    help plz its doing my head in
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts

    var plus = new Image();
    plus.src = "images/plusImage.gif";
    var minus = new Image();
    minus.src = "images/minusImage.gif";

    function toggle(objLink, imgName){
    document.images[imgName].src = (document.images[imgName].src==plus.src) ? minus.src:plus.src;
    objLink.blur();
    return false; //cancel action of href
    }

    ...

    <img src="http://www.simonsgroup.com/kamtoolbox/images/plusImage.gif" border="0" align="absmiddle" name="A4279028BD175F3380256DBB005182C7">
    <a class="expandable" href="#" onclick="return toggle(this,'A4279028BD175F3380256DBB005182C7')">Consultant contact</a><br>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts


    spent ages tyrying this last night - im assuming that it was more the lack of knowledge than logic as my logic seemed ok...

    thanks a million
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson


  •  

    Posting Permissions

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