469,929 Members | 1,415 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

fire an image button click event using javascript

..Hi all,

I want to catch an 'enter' keypress event on a web form and submit the form
as if a button had been clicked rather than the default post back behaviour.
I know the following javascript can be placed in the body tag to do this.

onkeydown="if(event.keyCode ==
13){document.getElementById('iBtnSubmit').onClick( );

This will work fine if 'iBtnSubmit' is an input type of 'Button' but the
problem I am having is that the button in question is an image button. This
is rendered by the server as an input type of 'image' which does not have a
click method. Does anyone have any idea of how I can recreate this behaviour
for an imagebutton?

Thanks, Andy
Nov 19 '05 #1
1 10625
Found a solution to this if anyone is interested. Instead of trying to fire a
click event set the focus on to the image button. This will then fire the
click event when the postback takes place. Again place this in the opening
<body> tag.

onkeydown="if((event.which ? event.which : event.keyCode) ==
13){document.getElementById('iBtnSubmit').focus(); "

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by ron | last post: by
4 posts views Thread by Mark Lingen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.