PDA

Click to See Complete Forum and Search --> : [JS]problems with onmouseover



skabszo
02-28-2007, 05:32 PM
Hi I have problem with onmouseover - i am using this script:

<script type="text/javascript">
last="d1";
function f(x){
document.getElementById(last).className='niewidocz na';
document.getElementById(x).className='widoczna';
last=x;
}
</script>and this css
.widoczna {
display: block;
}
.niewidoczna {
display: none;
}. I made this sample - i have one img which is a button

<a href="http://" onmouseover="f('d2')"><img src="picture.jpg" width="100px" height="20px"></a>

As you know this is simple - when smb will move moouse over this picture, some picture in the div with id="d2" will be visible. Everything works fine but.. i want to use it for two divs. I have tried to use sth like that onmouseover="f('d2';'d3')" but it doesn't work. I want to change text in div d3, and picture in d2 - with one mouse over on that picture. Is any solution of my problem?

dawsonk
02-28-2007, 06:58 PM
<html>
<head>
<STYLE type=text/css media=screen>
BODY{margin:0; padding:0; background:#fff}
.widoczna {display: block;}
.niewid {display: none;}
.hid {display: none;}
</STYLE>
<script type="text/javascript">
oldpic="d1";
oldtxt="d3";
function f(pic,txt){
document.getElementById(oldpic).className = 'niewid';
document.getElementById(oldtxt).className = 'niewid';
document.getElementById(pic).className = 'widoczna';
document.getElementById(txt).className = 'widoczna';
oldpic=pic;
oldtxt=txt;
}
</script>
</head>
<body>
<a href="http://" onmouseover="f('d2','d4')" onmouseout="f('d1','d3')">over here</a>
<div id=d1>one</div>
<div id=d2 class=hid>two</div>
<div id=d3>three</div>
<div id=d4 class=hid>four</div>
</body>
</html>