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

Image Swap Issue???

Status
Not open for further replies.

Mdiaz

Programmer
Jul 8, 2002
32
US
I think I've been cursed from javascipt because I am almost always unable to run even the simplest of routines. I will now publicly profess my incompetence in this langauge. I can not get the rollovers to work. It so simple yet I can't figure it. Please help.

I pasted whole page just incase I boned it elsewhere.


<%if session(&quot;XXXXXXX&quot;) <> &quot;XX&quot; Then
response.redirect &quot;/index.asp&quot;
End If%>
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<META NAME=&quot;description&quot; CONTENT=&quot;Your one stop shop for all your award needs. We manufacture and sell trophies, medals, glass etchings,
plaques and much more.&quot;>
<META NAME=&quot;keywords&quot; CONTENT=&quot;trophies, awards, medals&quot;>
<html>
<head>
<title>XXXXXXXXX</title>
</head>
<body background=&quot;/graphics/Bmarble3.jpg&quot;>
<!--#include virtual=&quot;/navigation.inc&quot;-->

<table width=&quot;550&quot; align=&quot;center&quot;>
<tr>
<td>
<H2 align=&quot;center&quot;>Awards Admin Page</H2>
<hr>
<div align=&quot;center&quot;><P><a href=&quot;/admin/Add_Award.asp&quot; onmouseover=&quot;rollover.scr='CAtext.gif';&quot; onMouseOut=&quot;rollover.scr='text.gif';&quot;
><img src=&quot;/graphics/CreateAward.gif&quot; alt=&quot;&quot; width=&quot;200&quot; height=&quot;50&quot; border=&quot;0&quot;></a></P></div>

<div align=&quot;center&quot;><P>
<a href=&quot;/admin/Edit_Award.asp&quot; onmouseover=&quot;rollover.scr='EAtext.gif';&quot; onMouseOut=&quot;rollover.scr='text.gif';&quot;>
<img src=&quot;/graphics/EditAward.gif&quot; alt=&quot;&quot; width=&quot;200&quot; height=&quot;50&quot; border=&quot;0&quot;></a>
</P></div>
<div align=&quot;center&quot;><P>
<a href=&quot;/admin/AdminLU.asp&quot; onmouseover=&quot;rollover.scr='TUtext.gif';&quot;
onMouseOut=&quot;rollover.scr='text.gif';&quot; >
<img src=&quot;/graphics/TableUpdate.gif&quot; alt=&quot;&quot; width=&quot;200&quot; height=&quot;50&quot; border=&quot;0&quot;></a>
</P></div>
</td>
<td>
<img name=&quot;rollover&quot; src=&quot;text.gif&quot; alt=&quot;&quot; width=&quot;250&quot; height=&quot;200&quot; border=&quot;0&quot; >
</td>
</tr>

</table>
<CENTER>
<p><%Call AdminFooter %></p>
</CENTER>
</body>
</html>
 
Don't panic my friend! Here's a simple rollover that's sure to work every time.

Insert this code within the <head> tags of your page.

Code:
<script language=&quot;JavaScript&quot;>
var imagesLoaded = false;

but1_over = new Image(); but1_over.src = &quot;images/button_on.gif&quot;;
but1_out = new Image(); but1_out.src = &quot;images/button_off.gif&quot;;

imagesLoaded = true;

function imgOverOne(which){
	if(imagesLoaded){
eval('document.but'+which+'.src = but'+which+'_over.src'); 
	}
}

function imgOutOne(which){
	if(imagesLoaded){
eval('document.but'+which+'.src = but'+which+'_out.src');
	}
}
</script>

... and when you wish to create a rollover link insert the onmouseover onmouseout within the <a> tag. Remember to also add an 'id' to your image.

Code:
<a onmouseover=imgOverOne(1); onmouseout=imgOutOne(1); href=&quot;my_page.asp&quot;><img id=&quot;but1&quot; name=&quot;but1&quot; border=&quot;0&quot; src=&quot;images/button_off.gif&quot;></a>

When you want to add more buttons replace all the 1's with 2's, 3's etc...

Hope this helps!
Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top