Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 767
  • Last Modified:

How to make an Input field recognize the enter keystroke

I've got an HTA that has 1 input box and 8 read only return boxes.  I want the 1 input box to submit the user's entry on the enter keystroke.  I know the input box has to have the onKeyDown(callsub), but what does the sub do?
0
piattnd
Asked:
piattnd
  • 4
  • 2
1 Solution
 
piattndAuthor Commented:
So an update on this, I got it so it recognizes the enter keystroke, now how to I tell the SUB to click the submit button if the keystroke = enter?
0
 
hieloCommented:
>> click the submit button if the keystroke = enter
are you trying to submit the form?
If yes, then make sure you give the form an id:
<form id="theForm">
 
and when you detect the Enter you then execute:
document.getElementById("theForm").submit()
 
If you are NOT trying to submit the form, but instead are trying to execute some onclick function on the button:
<input type="button" onclick="foo()">
 
then simply call the function directly when you detect the enter key

Open in new window

0
 
piattndAuthor Commented:
Thanks much, I actually had hit up a friend who helped me understand what was going on.  I appreciate the response (yours was what I was looking for)!
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
RobSampsonCommented:
Hi, you can add this to you <body> tag in the HTML section:
<body onkeypress='vbs:Default_Buttons'>

and then add this in your <script> section:
Sub Default_Buttons
      If Window.Event.KeyCode = 13 Then
            btn_install.Click
      End If
End Sub


where you can change btn_install.Click to the name of the OK button control.

Regards,

Rob.
0
 
hieloCommented:
Hmm, that grade simply seems inappropriate. The answer was technically sound. So I "lost" 500pts for no reason. Perhaps you should read:
http://www.experts-exchange.com/help.jsp#hi504
0
 
piattndAuthor Commented:
My fault hielo, I gave you a B because I had already found solution prior to your posting.... :-/
0
 
piattndAuthor Commented:
Rob,

I'll give that a shot on the next HTA I use.  I was actually curious if there was a way to just "push" the button through code, which appears to be what you suggested.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now