View Full Version : modify


Elentari
06-07-2003, 12:37 AM
Can someone who knows javascript please modify this so that it can be used several times on the same page. It's a script that changes text on mouseover. I'm trying to use it in a calendar that when you hover over a number, it will show the things I have to do for that day...this does exactly what I want it to but it only does it for one, I don't know how to make it do it for all the days in the month. Please help.


<head>
<script type="text/javascript">
function def(val) {
div1.innerHTML = val;
}
function change(val) {
div1.innerHTML = val;
}
</script>
</head>

<body>
<p id="div1" onmouseover="change('New Text');" onmouseout="def('Old Text');">Old Text</p>
</body>

amicus
06-07-2003, 02:02 PM
here you go, hope this helps :)

<html>
<head>
<script type="text/javascript">
/**
* Change the id to the value being passed in.
*/
function toggleText( id, value ) {
id.innerHTML = value;
}
</script>
</head>

<body>
<p id="div1" onmouseover="toggleText( this, 'New Text' );" onmouseout="toggleText( this, 'Old Text' );">Old Text</p>
<p id="div2" onmouseover="toggleText( this, 'New Text 2' );" onmouseout="toggleText( this, 'Old Text 2' );">Old Text 2</p>
</body>

Elentari
06-07-2003, 09:24 PM
That is EXACTLY what I wanted, brilliant. Thanks =)