Solved

Change image on click

Posted on 2009-04-06
4
683 Views
Last Modified: 2013-12-24
need to change this image on click this is not a form its simply an image that gets clcked for navigation.

Based on what i see above this is the part i put in header.

<script language = "javascript">
this.src='images/owners_small.gif';
</script>


This is code:


<p align="center"><img src="<cfoutput>#imagepath#</cfoutput>/signuptoday.gif" width="183" height="41" border="0" vspace="8" id = "affiliate" value = "Condo Affiliate: Fill out the form and you will be contacted soon." onclick="(this.src != 'images/owner_small.gif') "></p>

Open in new window

0
Comment
Question by:LeadCo
4 Comments
 
LVL 3

Assisted Solution

by:kingsob
kingsob earned 100 total points
ID: 24084109
here we go
<html>

  <head>

  </head>

  <body>

    <img src="1.png" onclick="this.src='2.png';"/>

  </body>

</html>

Open in new window

0
 
LVL 27

Accepted Solution

by:
azadisaryev earned 300 total points
ID: 24084231
no need for anything in the HEAD.
the below will change the image only if it is NOT already images/owners-small.gif

<p align="center"><img src="<cfoutput>#imagepath#</cfoutput>/signuptoday.gif" width="183" height="41" border="0" vspace="8" id = "affiliate" value = "Condo Affiliate: Fill out the form and you will be contacted soon." onclick="(this.src != 'images/owner_small.gif') this.src='images/owners_small.gif';"></p>

the js inside onclick event checks if the src of this image is 'images/owners_small.gif, and if it is not changes it to 'images/owners_small.gif'.

btw, there is no VALUE attribute for <img> tag. but there IS alt attribute, which you should always specify.

Azadi
0
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 100 total points
ID: 24084434
I do not see the point in changing the image unless you do something else when clicking

<p align="center">

  <img src="<cfoutput>#imagepath#</cfoutput>/signuptoday.gif" 

  width="183" height="41" border="0" vspace="8" id = "affiliate" 

  value = "Condo Affiliate: Fill out the form and you will be contacted soon." 

  onclick="(this.src = '<cfoutput>#imagepath#</cfoutput>/owner_small.gif') ">

</p>

Open in new window

0
 

Author Closing Comment

by:LeadCo
ID: 31567363
Thanks Guys!    to mplnqjan: The reason for hiding the image was because it is a naviagation image and when the ajax shows new content it is not neccessarry.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now