View Single Post
Old 11-16-2005, 01:31 PM   #1 (permalink)
Shocker
 
True Techie

Join Date: Oct 2005

Posts: 109

Shocker

Default Javascript string comparison?

Hey All,

I need some help with my javascript program. I need to write a program that diplays an image, and when clicked, it changes to a different image. And when you click on the 2nd image, it changes back to the 1st, and so on. I got the program to switch to the 2nd image, but can't get it to switch back. My instructor gave us a hint that we have to use string comparison? I've looked all through the book and w3schools, but can't find anything. Please help! What piece of code am I missing? Here's what I have so far:

<html>
<head>

<title>Javascript Assignment 4 Part 3</title>

<script language = "Javascript">

// Blue Jacket: http://www.newenough.com/product_pic...blue_front.jpg

// Red Jacket: http://www.newenough.com/product_pic.../red_front.jpg



//The function is called when the image in the body is clicked.
//The function changes the image source of 'Blue Jacket' to 'Red jacket'

function rollover ()


{
document.picture.src = "http://www.newenough.com/product_pictures/a/alpinestars_tz1_jacket/red_front.jpg";
}


</script>
</head>
<body>

<h1>Welcome to Switching Images!</h1>


<!-- there is an image tag below with the name picture that displays 'Blue Jacket'.
When the image is clicked, the 'rollOver()' function is called -->







</body>
</html>
Shocker is offline