Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Changing the image source with java script

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Is the image source can be changed with a java script.
(e.g on Onclick event or on clicking a button)
and If we have more that one images.
thanx in advance.
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im sure it can. i dont know exact code. i think you have to give the image a name in order to refer to it in javascript. im sure someone will give you a more complete answer.
I hate to say this but, your name does not comply with the Javaranch naming guidelines which can be found at http://www.javaranch.com/name.jsp
in particular you must have first and last name
please register again with a valid name.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adil,
there are several ways you can accomplish that
you can write function to handle that.
<script language="javascript">
function flipImage() {
imageName.src = "img_on.gif";
}
</script>

<body>
<img id="imageName" src="img_off.gif" onMouseOver=flipImage()>
</body>
so, first you need to id or name your image, then using some scripting change its current source to the one you want.
Keep in mind that id's and function names are case sensitive.
mocca az
[This message has been edited by mocca az (edited November 15, 2001).]
 
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic