Jump to content

Using keyboard instead of clicking  submit


robthewildman

Recommended Posts

 

I'm programming in classic asp / JavaScript. 

Okay, I have a screen full of *.mdb Records. Each  record is designated  by a radio button. I click a  record button and then click Another radio button to tell The computer what to do with it, and then  click submit. Instead of all that, I would like to just click that record and then press a key, like F6 for edit, F4 for move, F10 for delete, Etc. At the present time all I have to do is just press enter to activate a function that is default, but that's only one function. Just point me in the right direction and I'll figure it out.

Link to comment
Share on other sites

You can use keyevents for that for example:<!DOCTYPE ht

l<!DOCTYPE html>
<html>
<body>

<h3>Trigger Button Click on Enter</h3>
<p>Press the "Enter" key inside the input field to trigger the button.</p>

<input id="myInput" value="Some text..">
<button id="myBtn" onclick="javascript:alert('Hello World!')">Button</button>

<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
  if (event.keyCode === 13) {
   event.preventDefault();
   document.getElementById("myBtn").click();
  }
});
</script>

<!DOCTYPE html>
<html>
<body>

<h3>Trigger Button Click on Enter</h3>
<p>Press the "Enter" key inside the input field to trigger the button.</p>

<input id="myInput" value="Some text..">
<button id="myBtn" onclick="javascript:alert('Hello World!')">Button</button>

<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
  if (event.keyCode === 13) {
   event.preventDefault();
   document.getElementById("myBtn").click();
  }
});
</script>

</body>
</html>

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...