M
Marko Mikkonen
I'm trying to make code which does something when user clicks a row in a
table. I tried a javascript code from JS-Examples.com. It works on
Firefox, but not on Internet explorer 7. Here's the code:
<html>
<head>
<!--
This file retrieved from the JS-Examples archives
http://www.js-examples.com
1000s of free ready to use scripts, tutorials, forums.
Author: JS-X.com - http://js-x.com/contact/
-->
<style>
..c1 {background-color: #ACF;}
..c2 {background-color: #FCA;}
..c3 {background-color: #CFA;}
</style>
<script>
function ov(i)
{
document.getElementById(i).className="c3";
}
function ot(i,c)
{
document.getElementById(i).className=c;
}
function click(num)
{
alert("You choose Item #"+num);
}
</script>
</head>
<body>
<table>
<tr id=i1 class=c1 onclick='click(1)' onmouseover='ov("i1")'
onmouseout='ot("i1","c1")'><td>one</td><td>two</td><td>three</td></tr>
<tr id=i2 class=c2 onclick='click(2)' onmouseover='ov("i2")'
onmouseout='ot("i2","c2")'><td>one</td><td>two</td><td>three</td></tr>
<tr id=i3 class=c1 onclick='click(3)' onmouseover='ov("i3")'
onmouseout='ot("i3","c1")'><td>one</td><td>two</td><td>three</td></tr>
<tr id=i4 class=c2 onclick='click(4)' onmouseover='ov("i4")'
onmouseout='ot("i4","c2")'><td>one</td><td>two</td><td>three</td></tr>
<tr id=i5 class=c1 onclick='click(5)' onmouseover='ov("i5")'
onmouseout='ot("i5","c1")'><td>one</td><td>two</td><td>three</td></tr>
</table>
<BR><center><a
href='http://www.js-examples.com'>JS-Examples.com</a></center>
</body>
</html>
I also tried moving the onclick under td tags, but still IE 7 wouldn't
work. Onmouseover and onmouseout events seem to work fine in both IE7 and
Firefox.
Does the code work for you on IE7? What could be the problem?
-Marko
table. I tried a javascript code from JS-Examples.com. It works on
Firefox, but not on Internet explorer 7. Here's the code:
<html>
<head>
<!--
This file retrieved from the JS-Examples archives
http://www.js-examples.com
1000s of free ready to use scripts, tutorials, forums.
Author: JS-X.com - http://js-x.com/contact/
-->
<style>
..c1 {background-color: #ACF;}
..c2 {background-color: #FCA;}
..c3 {background-color: #CFA;}
</style>
<script>
function ov(i)
{
document.getElementById(i).className="c3";
}
function ot(i,c)
{
document.getElementById(i).className=c;
}
function click(num)
{
alert("You choose Item #"+num);
}
</script>
</head>
<body>
<table>
<tr id=i1 class=c1 onclick='click(1)' onmouseover='ov("i1")'
onmouseout='ot("i1","c1")'><td>one</td><td>two</td><td>three</td></tr>
<tr id=i2 class=c2 onclick='click(2)' onmouseover='ov("i2")'
onmouseout='ot("i2","c2")'><td>one</td><td>two</td><td>three</td></tr>
<tr id=i3 class=c1 onclick='click(3)' onmouseover='ov("i3")'
onmouseout='ot("i3","c1")'><td>one</td><td>two</td><td>three</td></tr>
<tr id=i4 class=c2 onclick='click(4)' onmouseover='ov("i4")'
onmouseout='ot("i4","c2")'><td>one</td><td>two</td><td>three</td></tr>
<tr id=i5 class=c1 onclick='click(5)' onmouseover='ov("i5")'
onmouseout='ot("i5","c1")'><td>one</td><td>two</td><td>three</td></tr>
</table>
<BR><center><a
href='http://www.js-examples.com'>JS-Examples.com</a></center>
</body>
</html>
I also tried moving the onclick under td tags, but still IE 7 wouldn't
work. Onmouseover and onmouseout events seem to work fine in both IE7 and
Firefox.
Does the code work for you on IE7? What could be the problem?
-Marko