• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to change image after a click

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a link which is an image which when clicked opens a new window.
I have the link disabled in order to avoid multiple clicks.now my question is
how do i change the image for example

By doing this im able to disable the link.So the user cannot click again
But how do i replace the on.gif with off.gif in addition to disabling the link
In short after i click the on image link once I want the link to b disabled (which im able to by 1 and 2)& also i
want the image to change to off.gif.

Please provide me with any example or for the above example.


Thanks
Preethi
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Change the src attribute of the image.
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hint: Use <div> tags to put two sections with diff images etc. Use javascript to display the div inline ot hide it.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Amit M Tank:
Hint: Use <div> tags to put two sections with diff images etc. Use javascript to display the div inline ot hide it.


Isn't that a bit heavy-handed when it's much easier to just set the src of the image?
 
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When changing the src of the image, the download time [from server to browser] comes into picture [ofcourse for the first time or depending on the caching policy set in the browser]. Here i have assumed the image is of considerable size [say more than 20KB and the link speed of the client machine having the browser is approx 256 kbps].

Also when we change src attribute of the image we should also change the width and height attribute of the new image [if new image is not of the same height and width as the previous image displayed else the image will look stretched or shrunken.
[ May 30, 2008: Message edited by: karthi keyan ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic