 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 3rd, 2003, 03:39 PM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
enter instead of tab
This may be a request that I have to tell the user to "forget it" but none the less I'll try. I have an html form with roughly 30 numeric fields which the user says she can fill in alot faster if she can use the 10 key and hit the enter on the 10key without having to use the second hand and reach for the tab key to move from field to field. I know I don't need to say this but when she hits the enter key it fires the submit button. Is there anything I can do for this poor soul?
|
|

September 4th, 2003, 04:59 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Try something like this which tests for enter key (13) and if it was pressed in a text box then it changes it to a tab (9) - seems to work in IE6 but I haven't tested it in any other browsers
Code:
<script language="javascript" type="text/javascript">
<!--
document.onkeydown = checkKey;
function checkKey(oEvent){
var oEvent = (oEvent)? oEvent : event;
var oTarget =(oEvent.target)? oEvent.target : oEvent.srcElement;
if(oTarget.type=="text" && oEvent.keyCode==13)
//return false;
oEvent.keyCode = 9;
}
// -->
</script>
|
|

September 4th, 2003, 03:25 PM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
That script rocks man, thanks.
|
|

February 24th, 2005, 01:26 PM
|
|
Registered User
|
|
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This enter key code works great accept when it gets to an Visual Interdev ASP dropdown box. . great work but do you have any suggestions for the dropdowns? You can only use the tab key in the dropdowns.
thank you
<script language="javascript" type="text/javascript">
<!--
document.onkeydown = checkKey;
function checkKey(oEvent){
var oEvent = (oEvent)? oEvent : event;
var oTarget =(oEvent.target)? oEvent.target : oEvent.srcElement;
if(oTarget.type=="text" && oEvent.keyCode==13)
//return false;
oEvent.keyCode = 9;
}
// -->
</script>
[/code]
[/quote]
tpiro
|
|

February 25th, 2005, 04:53 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
that's because the original script was deliberately restricted to text boxes only, by adding the part if(oTarget.type=="text" ...
if you want to extend it to other html elements like the select you can add those types in too:
if((oTarget.type=="text" || oTarget.type=="select-one" || oTarget.type=="select-multiple")&& oEvent.keyCode==13)
hth
Phil
|
|

March 9th, 2005, 10:26 PM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
Nice script! I'm trying to make it work in Mozilla/Firefox besides IE; but it doesn't work for some reason (the page form is submitted instead and tab emulation doesn't work). I changed the event handler code to the following:
Code:
if(document.all)
{
document.onkeydown = checkKey; // IE
}
else
{
document.addEventListener('keydown', checkKey, false); // Mozilla
}
Any clues on how to make it work in Mozilla/Firefox.
Thanks!
|
|

March 10th, 2005, 06:18 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
the original should work in Mozilla/Firefox as they both support the syntax document.onkeydown = checkKey . And these 2 lines:
var oEvent = (oEvent)? oEvent : event;
var oTarget =(oEvent.target)? oEvent.target : oEvent.srcElement;
have been used to cater for either the IE or Moz method of passing the event and getting the target.
Did you try the original before you modified it?
I don't have access to a Mozilla or Firefox browser at the moment to try it out, but I'll give it a go later.
rgds
Phil
|
|

March 13th, 2005, 01:27 AM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Phil,
Thanks for your reply. I tried the original code (posted by you back in 2003) and it doesn't seem to work in Mozilla/Firefox. It works just fine in IE6. In Firefox, the form is submitted and the page is reloaded if the enter key is pressed. I'm not quite sure what could be the problem. I would really appreciate if you can have a look at it and help me resolve this problem.
Cheers!
|
|

March 14th, 2005, 06:29 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
While researching this problem I came across this article which claims that Mozilla based browsers won't let you change the keyCode in script, so maybe there is no way to make it work in these browsers
http://www.faqts.com/knowledge_base/view.phtml/aid/1661
|
|

March 31st, 2005, 09:00 AM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
I already searched a long time for code to use enter as a tab. Now I found this, i pasted it into my aspx page but it doesn't work.
Can someone tell me what could be wrong?
Thx
|
|
 |