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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Script - JavaScript newbie...

Status
Not open for further replies.

Dineen

Programmer
Jun 20, 2001
16
0
0
US
I don't know much at all about JavaScript, but I'm trying to do an image change on a link hover. The image changes on another part of the page. The error I receive is "document(...) is null or not an object".

Here is my code:

<script language=&quot;JavaScript&quot;>
<!-- Hide the script from old browsers -- >
img0_on = new Image(50,50);
img0_on.src=&quot;amy.jpg&quot;;
img0_off = new Image(50,50);
img0_off.src=&quot;dineenjohn.jpg&quot;;

img1_on = new Image(50,50);
img1_on.src=&quot;amyapril.jpg&quot;;
img1_off = new Image(50,50);
img1_off.src=&quot;dineenjohn.jpg&quot;;

img2_on = new Image(50,50);
img2_on.src=&quot;aprilrick.jpg&quot;;
img2_off = new Image(50,50);
img2_off.src=&quot;dineenjohn.jpg&quot;;

img3_on = new Image(50,50);
img3_on.src=&quot;badjohn.jpg&quot;;
img3_off = new Image(50,50);
img3_off.src=&quot;dineenjohn.jpg&quot;;

img4_on = new Image(50,50);
img4_on.src=&quot;bibi.jpg&quot;;
img4_off = new Image(50,50);
img4_off.src=&quot;dineenjohn.jpg&quot;;

img5_on = new Image(50,50);
img5_on.src=&quot;chrisdineen.jpg&quot;;
img5_off = new Image(50,50);
img5_off.src=&quot;dineenjohn.jpg&quot;;

img6_on = new Image(50,50);
img6_on.src=&quot;dadjohn.jpg&quot;;
img6_off = new Image(50,50);
img6_off.src=&quot;dineenjohn.jpg&quot;;

img7_on = new Image(50,50);
img7_on.src=&quot;dineenhosp.jpg&quot;;
img7_off = new Image(50,50);
img7_off.src=&quot;dineenjohn.jpg&quot;;

img8_on = new Image(50,50);
img8_on.src=&quot;dineenjohn.jpg&quot;;
img8_off = new Image(50,50);
img8_off.src=&quot;dineenjohn.jpg&quot;;

img9_on = new Image(50,50);
img9_on.src=&quot;dineenjohn2.jpg&quot;;
img9_off = new Image(50,50);
img9_off.src=&quot;dineenjohn.jpg&quot;;

img10_on = new Image(50,50);
img10_on.src=&quot;dyanne.jpg&quot;;
img10_off = new Image(50,50);
img10_off.src=&quot;dineenjohn.jpg&quot;;

img11_on = new Image(50,50);
img11_on.src=&quot;dyron.jpg&quot;;
img11_off = new Image(50,50);
img11_off.src=&quot;dineenjohn.jpg&quot;;

img12_on = new Image(50,50);
img12_on.src=&quot;john.jpg&quot;;
img12_off = new Image(50,50);
img12_off.src=&quot;dineenjohn.jpg&quot;;

img13_on = new Image(50,50);
img13_on.src=&quot;johnron.jpg&quot;;
img13_off = new Image(50,50);
img13_off.src=&quot;dineenjohn.jpg&quot;;

img14_on = new Image(50,50);
img14_on.src=&quot;lilchris.jpg&quot;;
img14_off = new Image(50,50);
img14_off.src=&quot;dineenjohn.jpg&quot;;

img15_on = new Image(50,50);
img15_on.src=&quot;mom.jpg&quot;;
img15_off = new Image(50,50);
img15_off.src=&quot;dineenjohn.jpg&quot;;

img16_on = new Image(50,50);
img16_on.src=&quot;mom2.jpg&quot;;
img16_off = new Image(50,50);
img16_off.src=&quot;dineenjohn.jpg&quot;;

function over_image(parm_name)
{
document[parm_name].src = eval(parm_name + &quot;_on.src&quot;);
}
function off_image(parm_name)
{
document[parm_name].src = eval(parm_name + &quot;_off.src&quot;);
}
// End Hiding Here -->
</script>
 

function over_image(parm_name)
{
eval(&quot;document.&quot; + parm_name + &quot;.src = &quot; + parm_name + &quot;_on.src&quot;)
}

function off_image(parm_name)
{
eval(&quot;document.&quot; + parm_name + &quot;.src = &quot; + parm_name + &quot;_off.src&quot;)

}

-----------------------------------------------------------------
&quot;The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.&quot;
- unknown

mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top