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

how to change image

Status
Not open for further replies.

donman2006

Programmer
Joined
Jul 30, 2006
Messages
2
Location
CA
Hi,

I change the image when person put the mouse on the image. How can I permanently change the image, when someone click on it and go to the next page?

<a href='#' onclick="changeText(1)"><img src="images/b1.jpg" name="Image1" width="84" height="34" border="0" id="Image1" onMouseOver="MM_swapImage('Image1','','images/b1_on.gif',1)" onMouseOut="MM_swapImgRestore()"></a>

<a href='#' onclick="changeText(2)"><img onMouseOver="MM_swapImage('Image2','','images/b2_on.gif',1)" onMouseOut="MM_swapImgRestore()" src="images/b2.jpg" name="Image2" width="101" height="34" border="0" id="Image2"></a>

<script language="JavaScript" type="text/JavaScript">

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}


function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

</script>

 
when someone goes to the next page? if you really need a javascript solution, then you'll need to do this by either passing a variable through the query string or using cookies to determine if the image has been changed.

[&raquo;] Getting Querystring Values
[&raquo;] Getting Cookie Values



*cLFlaVA
----------------------------
[tt]somebody set up us the bomb![bomb][/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
actually it will not be next page, it will jump to a differnt <div> on the same page. I was hoping if there is some easy solution.
 
you will need to be more clear with what you are trying to accomplish. i'm quite confused. if you want the image to stay as it is after the user has put their mouse over the anchor, then simply remove the onmouseout function from your code.



*cLFlaVA
----------------------------
[tt]somebody set up us the bomb![bomb][/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top