Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onmouseover button

Status
Not open for further replies.

Hobeau

MIS
Apr 19, 2004
77
US
Hey guys, I'm new to javascript, so this is pretty easy. I'm trying to write a java script to change an image button so that onmouseover it will send back the string "a", and onmouseout it will send back the string "b" to my javascript function. If the string is "a", then I want it to load the highlighted image button, if it is string "b", then I want it to load the normal picture button. I know how to write most of it, but I just don't know how to load the picture into the table cell because I don't know how to reference the table cell. Here's my code:

<script language="javascript">
function highlight(img){
if(img = "a") {

}
}
</script>

thanx
 
here's some updated code (I'm setting the webpage up on my computer first before I upload it to the web domain,, hence the pictures are on my C: drive)

<script language="javascript">
function highlight(img){
if(img = "a") {
test.src="C:\Documents and Settings\Beau\Desktop\TLI projects\website stuff\buttons\a2.gif"
}
else if(img="b") {
test.src="C:\Documents and Settings\Beau\Desktop\TLI projects\website stuff\buttons\a1.gif"
}
}
</script>
 
You don't have to worry about which cell it is in. If you set the onmouseover and onmouseout events correctly, it should be easy:

Code:
<img src='defaultButtonImage.jpg' onmouseover='highlight([b]this[/b], "a");' onmouseout='highlight([b]this[/b], "b");' />

Then, in the JavaScript:

Code:
function highlight(img, code)
{
 if(code == 'a')
  img.src = 'mouseOverButtonImg.jpg';
 else //if(code == 'b')
  img.src = 'defaultButtonImage.jpg';
}

I think that's all you need. 'hope that helps.

--Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top