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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onMouseOver-SeveralImages-and disable-enable problem

    Hi everybody;

    I hava a code ==>

    <script language="JavaScript">

    var prevClicked = "";
    Imgpath="../images/styleguide/";

    function staySet(curr,imgName){


    tmpStr = curr.toString();
    if (prevClicked == "")
    {
    document.getElementById(curr).disabled = true;
    prevClicked = curr;
    }
    else
    {
    document.getElementById(prevClicked).disabled = false;
    document.getElementById(curr).disabled = true;
    prevClicked = curr;
    }
    }


    function SwapImage(curr,imgName) {

    tmpStr = curr.toString();
    var swap = event.type;

    if (swap == 'mouseover')
    {
    document.getElementById(curr).src=Imgpath+imgName+'_prs.gif'
    document.getElementById(curr).disable=false;
    }

    if (swap == 'mouseout')
    {
    document.getElementById(curr).src=Imgpath+imgName+'_def.gif'
    }


    }
    </script>




    Inthis code ="document.getElementById(prevClicked).disabled = false;"
    part doesn't work...So my complete code become a ruin? if somebody knows hao can i enable or disable a image button???

    Thanks for your consideration


    rayesteq

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    You are getting the event type inside a function which will return "click"

    var swap = event.type;

    therefore your mouseout and mouseover arguments are not valid.

    Are you trying to do an image rollover?
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    onmouseover="SwapImage(imagId,'imgPath')"
    onmouseout="SwapImage(imgId,'imgPath')"


    onclick="javascript:staySet(imgId,'imgName')"
    href="<#apppath>?layoutid=6001&node=<#insert field="node">"

    I use something like that to call the function staySet()...Actualy I controlled if it gets into this function with alerts ; yes it goes into this function but the disabled=false or true part doesn't work?

    I actualy want to make an image rollover yes; but moreover when the user clicks on an image I want my image preserves its last visiaul stituation until user clicks another one...


    Meanwhile Thanks for your quick reply

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Here's a script I have that does what you want, just amend the image info



    <script language="JavaScript">
    <!--
    var Images = new Array("images/pic2_tn.jpg","images/pic1_tn.jpg","images/pic3_tn.jpg") // list images to preload
    var preloadImages=new Array() // preloads images
    for (i=0;i<=Images.length-1;i++) {
    preloadImages[i]=new Image()
    preloadImages[i].src=Images[i]
    }

    LastID = ""

    function m_over(id){
    (LastID != id?document.getElementById(id).src = "images/pic02_tn.jpg":"")
    }

    function m_out(id){
    (LastID != id?document.getElementById(id).src = "images/pic01_tn.jpg":"")
    }

    function m_click(id){
    document.getElementById(id).src = "images/pic03_tn.jpg"
    if (LastID != ""){
    (LastID != id?document.getElementById(LastID).src = "images/pic01_tn.jpg":"")
    }
    LastID = id
    }
    // -->
    </script>

    <a href="#null" onMouseOver="m_over('image1');" onMouseOut="m_out('image1')" onClick="m_click('image1')"><img src="images/pic01_tn.jpg" border="0" id="image1"></a>

    <a href="#null" onMouseOver="m_over('image2');" onMouseOut="m_out('image2')" onClick="m_click('image2')"><img src="images/pic01_tn.jpg" border="0" id="image2"></a>

    <a href="#null" onMouseOver="m_over('image3');" onMouseOut="m_out('image3')" onClick="m_click('image3')"><img src="images/pic01_tn.jpg" border="0" id="image3"></a>

    <a href="#null" onMouseOver="m_over('image4');" onMouseOut="m_out('image4')" onClick="m_click('image4')"><img src="images/pic01_tn.jpg" border="0" id="image4"></a>

    <a href="#null" onMouseOver="m_over('image5');" onMouseOut="m_out('image5')" onClick="m_click('image5')"><img src="images/pic01_tn.jpg" border="0" id="image5"></a>

    <a href="#null" onMouseOver="m_over('image6');" onMouseOut="m_out('image6')" onClick="m_click('image6')"><img src="images/pic01_tn.jpg" border="0" id="image6"></a>
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

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