|
-
Jan 21st, 2005, 02:07 PM
#1
Thread Starter
Hyperactive Member
Keystroke?
I want to make a command button default, meaning that when the user presses the enter button, the button code is executed. How do I do that?
-
Jan 21st, 2005, 04:53 PM
#2
Re: Keystroke?
 Originally Posted by GamerMax5
I want to make a command button default, meaning that when the user presses the enter button, the button code is executed. How do I do that?
In HTML? If you have a submit button that becomes the default button. If you have more then one form then submit button for the active form (the form which has focus) will be executed.
If its not HTML you are talking about, then please clarify.
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jan 22nd, 2005, 02:06 PM
#3
Thread Starter
Hyperactive Member
-
Jan 22nd, 2005, 10:06 PM
#4
Re: Keystroke?
 Originally Posted by GamerMax5
In VBScript.
I am sorry, i am kinda lost. Can you explain what exactly you are trying to do?
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jan 23rd, 2005, 09:20 AM
#5
Hyperactive Member
Re: Keystroke?
He wants to detect the [ENTER] key and then submit a form -- no matter what one the page has focus...
so something like:
Code:
<head>
<script language="VBScript">
Function handleKeyPress
If pressedKey = 13 Then document.MyForm.submit
End Function
</script>
<body onKeyPress="handleKeyPress()">
I know in there somewhere you have to pass the event data, but I don't know where. Also I'm not sure if "document.MyForm.submit" is exactly correct, but it should point you down the right path.
"I don't want to live alone until I'm married" - M.M.R.P
-
Jan 23rd, 2005, 12:56 PM
#6
Re: Keystroke?
 Originally Posted by Disiance
He wants to detect the [ENTER] key and then submit a form -- no matter what one the page has focus...
so something like:
Code:
<head>
<script language="VBScript">
Function handleKeyPress
If pressedKey = 13 Then document.MyForm.submit
End Function
</script>
<body onKeyPress="handleKeyPress()">
I know in there somewhere you have to pass the event data, but I don't know where. Also I'm not sure if "document.MyForm.submit" is exactly correct, but it should point you down the right path.
Well then the following should be what exactly he is looking for. Note it will only work in IE.
HTML Code:
<html>
<head>
<script language="VBScript">
Function handleKeyPress
if (window.event.keyCode =13) then
myfunction
end if
End Function
function myFunction
msgbox "You have pressed Enter Key"
'Your default code goes here......
end function
</script>
<body onKeyPress="handleKeyPress()">
<form>
<input type=text>
<br>
<input type=text>
<br>
<input type=text>
<select>
<option>hello</option>
</select>
<body
</html>
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|