Calling a Button on pressing Enter [Web]

A form in web with 2 fields, 2 buttons , for example fields are Name, Age and buttons are Save Name, Save Age

If I enter Name and press enter, the form says 'form processed'. When the document is again opened, and I enter the age.


I want 'Save Name' button to be called/pressed when name is entered. And when the doc is opened and age is entered, by pressing enter key, I want 'Save Age' button to be called.

whats the way to call a button (or generate its formulas) by pressing Enter key ?

Thanks
ninteen83Asked:
Who is Participating?
 
Joep8020Connect With a Mentor Commented:
Also:

Give the button an id (on the HTML tab of the button properties) e.g. buttonID, then use the script:
if(event.keyCode==13){
document.getElementById("buttonID").click();
}
0
 
ninteen83Author Commented:
2nd para was incomplete.

" If I enter Name and press enter, the form says 'form processed'. When the document is again opened, and I enter the age, and press enter, it again says 'form processed'.  "
0
 
madheeswarCommented:
This is becasue you don't have any $$Return field for redirecting to any page.

Also, you can validate those 2 fields and use on Submit event to process the form.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
ninteen83Author Commented:
I'm using @URLOpen in the buttons. My question was how can I prevent the form being saved and display form process by press Enter key, Pressing Enter should process the formulas in Save Name/Save Age buttons
0
 
madheeswarCommented:
In the onKeydown event of the form,
place below code:

if(event.keyCode==13){
return false;
}

0
 
ninteen83Author Commented:
it worked. thanks
0
All Courses

From novice to tech pro — start learning today.