Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7851683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:14:23+00:00 2026-06-02T19:14:23+00:00

I know I have to be doing something wrong, but again I don’t fully

  • 0

I know I have to be doing something wrong, but again I don’t fully understand what I’m doing as it is.
I’m creating a form which will have multiple buttons linked to JavaScript functions to do stuff. I’m at the very basic point of having these two buttons on the same page, and when you onMouseOver, onMouseDown, onMouseUp, onMouseOut it changes the image of my button.

I know there are other ways to do this (better ways) but I’m trudging on in this direction to at least get a better understanding of how JavaScript works. I know I’ll have somewhat more complicated things to do down the road that may require something like this and I want to be sure I understand it when I get there.

The problem I’m having is that the second button does not do anything when you try to use it. The first button works fine, but the second button doesn’t And when you try to use the second button, it makes the first one go off. So if I onMouseOver button 2, button 1 will show the affect. I tried copying my image files into a new set so they aren’t using the same images, but that just showed me what when I use button 2, the functions set up for button 2 are being applied to button 1.

Anyway, here’s the HTML code….

<input type="hidden"  value="0" id="theValue"  /> 
<p><a  href="javascript:addElement()"  ><img id="button" onMouseOver="hover_over()"
onMouseOut="hover_off()"  onMouseDown="click_add()" onMouseUp="release()"   
src="images/add_default.png" name="add" width="43" height="21"></a></p>


<input type="hidden"  value="0" id="theValue2"  /> 
<p><a href="javascript:addProduct()"  ><img id="button2"  
onMouseOver="hover_over_second()" onMouseOut="hover_off_second()" 
onMouseDown="click_add_second()" onMouseUp="release_second()"  
src="images/add_default2.png" name="add2" width="43" height="21"></a></p>

And here is the JavaScript….

////
//----------------Button Animation 1-------------------
////

function hover_off() {
document.images.add.src='images/add_default.png';   
}

function hover_over() {
document.images.add.src='images/add_hover.png';
}

function click_add() {
document.images.add.src='images/add_click.png';
}

function release() {
document.images.add.src='images/add_hover.png';
}
////
//---------------------------------------------------
////

////
//----------------Button Animation 2-------------------
////
function hover_off_second() {
document.images.add.src='images/add_default2.png';

}
function hover_over_second() {
document.images.add.src='images/add_hover2.png';
}
function click_add_second() {
document.images.add.src='images/add_click2.png';
}
function release_second() {
document.images.add.src='images/add_hover2.png';
}
////
//---------------------------------------------------
////

What am I doing wrong here? How do I get these links to actually work separately from each other?

Please teach me wise ones. I know this has to be stupid simple.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:14:27+00:00Added an answer on June 2, 2026 at 7:14 pm

    You are targetting the same element in your second button handler, it should be add2 not add like the first one that’s why the first element src attribute is changed instead of the other.

    function hover_off_second() {
    document.images.add2.src='images/add_default2.png';
    }
    function hover_over_second() {
    document.images.add2.src='images/add_hover2.png';
    }
    function click_add_second() {
    document.images.add2.src='images/add_click2.png';
    }
    function release_second() {
    document.images.add2.src='images/add_hover2.png';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know what I'm doing wrong here. I have a ListBox whose DataContext
I don't know what i am doing wrong but my onresize works fine in
I know we have ILdasm, but is there any tool out there that will
does anybody know if it's possible (or have experience doing so) to simply bundle
1st I have to say I know nothing bout php. I was actually doing
Let's say I have an array, and I know I'm going to be doing
I know there have been a few threads on this before, but I have
I know there have been some similar questions to this, but they haven't helped
This should so work. Please tell me I'm doing something wrong. Here's the code:
I am quite new to Visual Studio so don't know if I am doing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.