问题
I have a page with one field only. How can user submit the page by pressing 'Enter' without having to click the 'Submit' button? User should therefore be able to either press 'Enter' or click 'Submit'. Thank you.
回答1:
APEX text items have a property "Submit when Enter pressed". Set this to Yes and you are almost done. The APEX request is set to the name of the item so that you can, if you need to, have submit processing that depends on this e.g. PL/SQL Condition:
:request in ('SUBMIT','P1_MY_TEXT_ITEM')
回答2:
What is your APEX version ?
If you are using APEX 4, you can try this JQuery code :
$('#YOUR_TEXTFIELD_ID').keyup(function(e) {
if (e.keyCode == '13')
$('#YOUR_BUTTON').trigger('click');
});
It works only if any onclick event has been defined for the button, else simply call apex.submit(...) instead.
来源:https://stackoverflow.com/questions/9937791/apex-how-to-submit-page-when-enter-pressed-on-field