how to set default button on a page

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

xren
Ebase User
Posts: 272
Joined: Fri Dec 14, 2012 2:55 pm
Location: Ottawa

how to set default button on a page

#1

Postby xren » Tue Mar 26, 2013 2:18 pm

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
0 x

Steve
Moderator
Moderator
Posts: 421
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

#2

Postby Steve » Tue Mar 26, 2013 2:48 pm

I do not think this can be changed. The first button will always be the default.

Steve
0 x

xren
Ebase User
Posts: 272
Joined: Fri Dec 14, 2012 2:55 pm
Location: Ottawa

#3

Postby xren » Tue Mar 26, 2013 2:54 pm

How is the button count as first or second button? Is because the position or control name?
0 x

User avatar
Wai
Moderator
Moderator
Posts: 165
Joined: Wed Sep 12, 2007 9:04 am
Location: Sandy, UK
Contact:

#4

Postby Wai » Tue Mar 26, 2013 2:55 pm

Hi Xiaoli,

You can use JQuery to set the Enter Key button:

Code: Select all

<script>
$&#40;document&#41;.keypress&#40;function&#40;event&#41; &#123;
    var keycode = &#40;event.keyCode ? event.keyCode &#58; event.which&#41;;
    if&#40;keycode == '13'&#41; &#123;
        jQuery&#40;'#submit'&#41;.focus&#40;&#41;.click&#40;&#41;;
        return false;
    &#125;
&#125;&#41;;
</script>
Where there is a button on your page which has an ID of submit
And keycode 13 represents the Enter Key on Qwerty keyboard.
0 x

Steve
Moderator
Moderator
Posts: 421
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

#5

Postby Steve » Tue Mar 26, 2013 3:02 pm

xren wrote:How is the button count as first or second button? Is because the position or control name?
It is just the position on the page when output. The button should be output as an input with the attribute type='submit'

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 12 guests