Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

onClick() doesn't work for Image, any work around!!

 
Kanan Jariwala
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
In my requirement, i have more than one images(that act like buttons), when i click on any of the imgages,
1)onClick should get invoked
2)Within the onClick()Script some hidden Input Types are set dynamically
3)the form is then submitted.
Note: onClick() works in IE , but not in Netscape.
I am looking out for a solution that will work in both
thanks
kanan
 
Sid Sharama
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
make image an href like
<a href="some action" onClick='dosomejavascript()'><img src='pic.gif'></a>
it should work fine.in javascript you can even change the image
by specifying a new src.

regards,
sri
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to be a little careful with making an image into a link. Some browsers will link to the specified URL as well as running the onClick.
The best solution I have found is to make the image into a link,
but link to a "javascript" URL. For example:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic