PDA

View Full Version : swith images on mouse events for list of video links



HarryPutnam
06 Sep 2009, 11:02 AM
Example of my problem:

HERE (http://www.jtan.com/~reader/t/t1.html)

The code is derived from a site offering some advice for js and html:

HERE (http://www.javascript-coder.com/button/javascript-button-p1.phtml)

The example of mine tries to use an image as hyperlink... and use mouse events for certain actions.

Aside from possibly being the worst js code humanly possible...once I slaughtered the code from the site mentioned above, I'm not getting how to arrange things so that a mouse over event switches an image , as does mousedn and mouseup, And (and this is the rub for me) repeating the setup in the same way for a list of quicktime video links.

I've got it to work for one row in the table I'm using to attempt some kind of formatting.

I'm told `css' is a better way for that but I'm completely ignorant about how to use `css'. So, for now I'm using a table to get at the js question.

The idea is for viewer to see three red dots at the front of each item being offered.

Mouseover is supposed to switch to a green arrow... mousedn is supposed to switch to 2 check marks. I wanted the check marks to persist, so for lack of knowing how to accomplish that... I let mouseup call the same image. (the check marks; Maybe just omitting any directive for mouseup would have the same effect?)

About the `image persisting after being clicked' question: It is really a separate question so I will probably start a different thread for that.

What I've done works for one list item... but fails for more than one.

The only active member of the list (2 in my example) is the bottom one. mouse events on the top one are carried out on the bottom one.

I tried to just change the name of all variables in the javascript, and the name given in the `img src=' section of the html code, for the second row... but clearly not what is needed. I changed the names shown below by incrementing the number in the names by 1.
I've only posted one row's worth but the next row uses the same code with the variables incremented.

And hopefully someone will look at the actual example (URL given above) and see the full code.

The basic code I've put here for convenience:


<table>
<tr>
<td valign=top >
<A href="./t2.html" onMouseOver="return changeImage()" onMouseOut= "return changeImageBack()"
onMouseDown="return handleMDown()" onMouseUp="return handleMUp()"
><img
name="jsbutton_0" src="./3dots.png" border="0"
alt="javascript button"></A> some nice video
<SCRIPT language="JavaScript">
var myimgobj_0 = document.images["jsbutton_0"];

function changeImage()
{
document.images["jsbutton_0"].src= "./aro1r-mo.png";
return true;
}
function changeImageBack()
{
document.images["jsbutton_0"].src = "./3dots.png";
return true;
}
function handleMDown()
{
document.images["jsbutton_0"].src = "./checks.png";
return true;
}
function handleMUp()
{
document.images["jsbutton_0"].src = "./checks.png";
return true;
}
</SCRIPT>
</tr>
</td><table>
<tr>
<td valign=top >
<A href="./t2.html" onMouseOver="return changeImage()" onMouseOut= "return changeImageBack()"
onMouseDown="return handleMDown()" onMouseUp="return handleMUp()"
><img
name="jsbutton_0" src="./3dots.png" border="0"
alt="javascript button"></A> some nice video
<SCRIPT language="JavaScript">
var myimgobj_0 = document.images["jsbutton_0"];

function changeImage()
{
document.images["jsbutton_0"].src= "./aro1r-mo.png";
return true;
}
function changeImageBack()
{
document.images["jsbutton_0"].src = "./3dots.png";
return true;
}
function handleMDown()
{
document.images["jsbutton_0"].src = "./checks.png";
return true;
}
function handleMUp()
{
document.images["jsbutton_0"].src = "./checks.png";
return true;
}
</SCRIPT>
</tr>
</td>