+ Reply to Thread
Results 1 to 5 of 5

Thread: Mouse behaviours

  1. #1
    bunglebrown is offline x10 Sophmore bunglebrown is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    157

    Mouse behaviours

    Just trying to get some images reacting the way I want in dreamweaver but cant seem to hit it.

    Code:
     
        <td height="50%"><a href="#" onmousedown="MM_swapImage('Image1','','phase3.jpg',1)" onmouseover="MM_swapImage('Image1','','Images/phase2.jpg',1)"><img src="Images/phase1.jpg" name="Image1" width="25" height="25" border="0" id="Image1" /></a></td>
    The image is changing for the rollover to phase 2 = good. It is changing on the mousedown to phase 3 = great. But once the image has been clicked and is once again rolled over it goes back to phase 2 . . whereas I want it to stay as phase 3.

    Also I have other images on the screen that will work in the same way and I want to make it so that only one of them can be pressed down at one time (phase 3), i.e. on clicking a different image to the one already selected it applies the behaviour (phase 3) to the newly selected image and resets the other (phase 1). I suspect this is quite simple but then everything is when you know how to do it. In faith and thankfulness.

  2. #2
    VPmase's Avatar
    VPmase is offline x10 Elder VPmase is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Dixon, IL, USA
    Posts
    914

    Re: Mouse behaviours

    Add this code to the <a> tag:

    onmouseout="MM_swapImage('Image1','','Images/phase1.jpg',1)"

  3. #3
    bunglebrown is offline x10 Sophmore bunglebrown is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    157

    Re: Mouse behaviours

    thanks for the response..

    . . .that action does however disable the phase 3 (onmousedown) part when you move from that icon which is not what I want to do.

    Id like rollovers which I have and once an image is clicked it for it to remain selected and only change if another image is selected - so only one can be selected at any one time.

    thanks again\.

  4. #4
    scopey is offline x10Hosting Member scopey is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    62

    Re: Mouse behaviours

    So you want the image to change to image2 when rolled over, but to image3 if clicked, and it not to change back to image2 if it is image3 on rollover?

    If so, you want to run a function on mouse over that checks if the src of the image is image3, then it will do nothing... Else, the image will change to image2. I would suggest you put the onmouseover and onmousedown function in the img tag, and not the a tag. Makes it easier to JS for it.

    Ie. In JS file:
    function mouseover(elem){
    if(this.src == 'Images/phase1.jpg') this.src = 'Images/phase2.jpg';
    }

    In img tag:
    ...onmouseover='mouseover(this)'...
    - When in doubt, refer to the PHP manual.

  5. #5
    bunglebrown is offline x10 Sophmore bunglebrown is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    157

    Re: Mouse behaviours

    that is the type of solution I expected but it hasn't quite worked, although I feel we're close.

    This is the JS:

    Code:
    function rollover(this)
    {
    if(this.src='Images/phase1.jpg') this.src='Images/phase2.jpg'
    }
    And this is how I've referenced the function:

    Code:
     
         <td height="50%"><a href="#" onmousedown="displayad()" onmouseover='rollover()'> <img src="Images/phase1.jpg" name="Image1" width="25" height="25" border="0" id="Image1" /></a></td>
    Any further pointers? ??

+ Reply to Thread

Similar Threads

  1. mouse pointer and searchability
    By Dorothy in forum Programming Help
    Replies: 1
    Last Post: 12-13-2007, 03:30 AM
  2. Revenge of the mouse
    By n4tec in forum Off Topic
    Replies: 8
    Last Post: 01-11-2006, 10:01 AM
  3. Sony : Keyboard and Mouse Support for PS3
    By subvertman in forum Gamer's Lounge
    Replies: 7
    Last Post: 09-07-2005, 05:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers