473,626 Members | 3,369 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onkeypress, enter and iexplorer

Hello:

I'm having a problem with a simple javascript code that checks if the
enter key had been pressed or not. The code works propertly in mozilla,
but in iexplorer it only works one time, the second one the event isn't
throw any more, and I can't catch it.

Anyone can help me?

this is the sample code

function searchIntro(oEv ent)
{
if (oEvento.keyCod e)
iAscii = oEvent.keyCode;
else if (oEvent.which)
iAscii = oEvent.which;
else
return false;
if (iAscii == 13)
{
sendData();
}

}

<input type="text" id ="textBoxNam e1" name="CCO" size="69"
onkeypress="Sea rchIntro(event) "></tr>

Thanks a lot

Dec 5 '05 #1
3 10006
Juan wrote on 05 dec 2005 in comp.lang.javas cript:
Anyone can help me?

this is the sample code

function searchIntro(oEv ent)
should be: SearchIntro(oEv ent)
case sensitive!!
{
if (oEvento.keyCod e)
should be: oEvent.keyCode
iAscii = oEvent.keyCode;
else if (oEvent.which)
iAscii = oEvent.which;
else
return false;
a return value is not used by onkeypress
if (iAscii == 13)
{
sendData();
}
}

<input type="text" id ="textBoxNam e1" name="CCO" size="69"
onkeypress="Sea rchIntro(event) "></tr>


A shorter version of your function is:

function SearchIntro(oEv ent){
if ((oEvent.keyCod e && oEvent.keyCode= =13)
|| (oEvent.which && oEvent.which==1 3)) {
sendData();
}

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Dec 5 '05 #2

Thanks evertjan, but the trouble's still here : I made a mistakes
copying function to this message :-), but the case sensitive is
correctly implemented.

It only works the first time, the second one, on Internet Explorer,
fails and doesn't capture any other onkeypress event.Mozilla runs fine
the code everytime I use it.

whats happening?

Juan

Evertjan. ha escrito:
Juan wrote on 05 dec 2005 in comp.lang.javas cript:
Anyone can help me?

this is the sample code

function searchIntro(oEv ent)


should be: SearchIntro(oEv ent)
case sensitive!!
{
if (oEvento.keyCod e)


should be: oEvent.keyCode
iAscii = oEvent.keyCode;
else if (oEvent.which)
iAscii = oEvent.which;
else
return false;


a return value is not used by onkeypress
if (iAscii == 13)
{
sendData();
}
}

<input type="text" id ="textBoxNam e1" name="CCO" size="69"
onkeypress="Sea rchIntro(event) "></tr>


A shorter version of your function is:

function SearchIntro(oEv ent){
if ((oEvent.keyCod e && oEvent.keyCode= =13)
|| (oEvent.which && oEvent.which==1 3)) {
sendData();
}

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


Dec 7 '05 #3
Juan wrote on 07 dec 2005 in comp.lang.javas cript:
Evertjan. ha escrito:
function SearchIntro(oEv ent){
if ((oEvent.keyCod e && oEvent.keyCode= =13)
|| (oEvent.which && oEvent.which==1 3))
sendData();
}


[please do not toppost on usenet]


Thanks evertjan, but the trouble's still here : I made a mistakes
copying function to this message :-), but the case sensitive is
correctly implemented.

It only works the first time, the second one, on Internet Explorer,
fails and doesn't capture any other onkeypress event.Mozilla runs fine
the code everytime I use it.

whats happening?


That depends on your function sendData().
Always try an adviced code on itself first.
This works every time in IE:

<script type='text/javascript'>

function SearchIntro(oEv ent){
if ((oEvent.keyCod e && oEvent.keyCode= =13)
|| (oEvent.which && oEvent.which==1 3)) {
alert('<return> detected');
}
}
</script>

<input onkeypress='Sea rchIntro(event) '>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Dec 7 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4189
by: Albert Wagner | last post by:
I have included a file below that tests onKeyPress in Opera 7.11. I am getting peculiar behavior. When the file is first loaded, pressing the keypad + causes the textarea to get physically larger on the screen, and pressing the keypad - causes the textarea to get physically smaller. I click on the scrollbar then this behaviour stops and subsequent keystrokes are displayed appropriately. Is this some kind of bug in Opera 7.11? ...
7
4094
by: Kev | last post by:
I need to make some specific alterations to some JavaScript in webpages in order to comply with government guidelines on accessibility. Apparently, whenever the OnClick event is used, it must be accompanied by an alternative OnKeyPress event. The guidelines are very vague and I am not sure what this means. I have used the following piece of JavaScript inside the cell of a table: onclick="window.open('http://www.etc') Do I need to...
4
1912
by: Jonas | last post by:
Hi! I have a web page where I want to intercept keypress events in an INPUT-tag and check if it is the Enter key, which calls another function that executes a search. My code runs on Netscape 7 for Windows, IE 6 for Windows and IE5.1 for Mac, but not on Netscape 7 for Mac. When I press the Enter key, the event gets caught but it does not get prevented and the search is never executed. The code looks like this:
11
31063
by: LilAndy23 | last post by:
How can I use the onKeyPress event handler in Firefox? onKeyPress doesn't seem to fire in Firefox.
1
2021
by: dhnriverside | last post by:
Hi I've got a form with a TextBox and an invisible button, and I've got it set so that pressing enter causes the button to click. WOrks fine, the forms submits on enter and my datalist refreshes (tis a search textbox/list). I'm trying to implement AJAX style behaviour (its an intranet) - so as you type in the box, it refreshes the results list. So far I've tried OnKeyPress="TextChange" - where TextChange is a public C#
1
1383
by: Simon Wigzell | last post by:
I have a simple function whose purpose is to return false onkeypress and then that character should not appear in the text field. On any browser I have tried on a PC the return false means that the key pressed character won't appear in the text field. On a MAC with Safari it will. Any idea how I can prevent the character from appearing in the text box for MAC Safari? This link is to a stripped down version that demonstrates the problem: ...
1
7488
by: vega80 | last post by:
Hi. I have a problem with assigning an onkeypress-function to dynamically created input-boxes.I want to put the content of an input-field into a tag-list when the user hits enter. This works fine the first time (when the input-field is created in a non-dynamical way). The next input-field is created dynamically by a function that is called when the user hits enter (the previously generated input-field will be hidden). Then I'm trying...
4
8730
by: Grant Merwitz | last post by:
Hi I am trying to implement the Microsoft Ajax.NET extensions to perform a lookup on a key press of a text box. What this will do is once a user enters a letter into the textbox, this will filter a list from a database and populate some filtered options for the user to choose in a seperate listbox. Any subsequent key presses will further filter this result set.
5
22007
by: hannie | last post by:
onKeyPress does not work in Firefox. If use tab to navigate each field and press "Enter" on "Next" button to submit form and process to the next form / page, IE works well even if without onKeyPress code. However, Firefox supresses onKeyPress on submit when "Enter" key is pressed. e.which and code="13" does not work for submit button at all in Firefox nor by changing code to focus(). e.g. use tab to navigate each field, when tab goes...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.