Hi
I have several buttons on a page. I would like to set one of them as the default button - when user press 'enter' the button is triggered as click button.
How can this be done?
Thank you,
Xiaoli
how to set default button on a page
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 272
- Joined: Fri Dec 14, 2012 2:55 pm
- Location: Ottawa
-
- Moderator
- Posts: 421
- Joined: Fri Sep 07, 2007 3:44 pm
- Location: Sandy, UK
- Contact:
-
- Ebase User
- Posts: 272
- Joined: Fri Dec 14, 2012 2:55 pm
- Location: Ottawa
- Wai
- Moderator
- Posts: 165
- Joined: Wed Sep 12, 2007 9:04 am
- Location: Sandy, UK
- Contact:
Hi Xiaoli,
You can use JQuery to set the Enter Key button:
Where there is a button on your page which has an ID of submit
And keycode 13 represents the Enter Key on Qwerty keyboard.
You can use JQuery to set the Enter Key button:
Code: Select all
<script>
$(document).keypress(function(event) {
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13') {
jQuery('#submit').focus().click();
return false;
}
});
</script>
And keycode 13 represents the Enter Key on Qwerty keyboard.
0 x
-
- Moderator
- Posts: 421
- Joined: Fri Sep 07, 2007 3:44 pm
- Location: Sandy, UK
- Contact:
It is just the position on the page when output. The button should be output as an input with the attribute type='submit'xren wrote:How is the button count as first or second button? Is because the position or control name?
Wai's response might be what you need if you want to override the enter key.
0 x
Who is online
Users browsing this forum: No registered users and 23 guests