[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Change image on click

Posted on 2009-04-06
4
Medium Priority
?
704 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Assisted Solution

by:kingsob
kingsob earned 400 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 1200 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 400 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This article discusses how to implement server side field validation and display customized error messages to the client.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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).

656 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