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

image swapping

Status
Not open for further replies.

estesflyer

Programmer
Dec 19, 2000
284
US
hello, im just starting out w/ javascript, and im learning it through the webmonkey tutorials. my "assignment" or whatever was to write an image swap program, like,you move your cursor over the image, and it'll change, move your mouse over the image again, and it'll change again. it has 3 diff images in it. here is the source code. its really confusing, but not the prompt part, just the actual image swapping part.


<html>
<head>
<title>title</title>
<script language=&quot;JavaScript&quot;>
<!-- hide me

var temp = &quot;&quot;;
var image1 = '/webmonkey/98/03/images2a/thau.gif';
var image2 = '/webmonkey/98/03/images2a/sky.gif';
var image3 = '/webmonkey/98/03/images2a/monkey.gif'

var user_name = prompt(&quot;What's your name&quot;, &quot;&quot;);
if (user_name == &quot;&quot;)
{
user_name = &quot;stranger&quot;;
}

// end hide -->
</script>


</head>
<body>


<h1>Browser Configuration</h1>
<h2>Welcome

<script language=&quot;JavaScript&quot;>
<!-- hide me
document.write(user_name);
// end hide -->
</script>

<a href=&quot;#&quot;
onMouseOver=&quot;temp=image1; image1=image2; image2=image3; image3=temp; document.the_image.src=image1;&quot;
onClick=&quot;document.brand_image.src=image1;&quot;>
<img src=&quot; name=&quot;the_image&quot; border=0></a>


-Rusty
 
-> there is NO question in your thread ... what are you looking for ??
-> if it's not working ... are you using ie ? &quot;the other browser&quot; ? is it normal that the image named &quot;brand_image&quot; is not here ? is it normal that you use onmouseover and the onclick and not onmouseout ??
 
im wanting to know what is happening here

<a href=&quot;#&quot;
onMouseOver=&quot;temp=image1; image1=image2; image2=image3; image3=temp; document.the_image.src=image1;&quot;

whats w/ the this eqauls that, and that equals something else, etc...

-Rusty
 
you set temp to image1, then image1 to image2 .... then image3 to temp --> this is the swapping ! what you've done is replacing image1 with image2, image2 with image3 and image3 with image1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top