...

View Full Version : Enter Key in Text Box



peterinwa
10-28-2006, 08:01 AM
I have a very complex page created with JavaScript, and I'm also using frames. It's a calculator, and with each calculation the image frame is re-drawn.

I have many pages (calculators) like this and they all work fine and all use text boxes. If I put the cursor in any text box and press the Enter key, nothing happens.

In a new page I am creating, when I do this it causes the page to reload.

I'm probably screwed the coding up somewhere, but I'm looking for hints. What should happen if you put the cursor in a text box and press Enter?

<input type=text size=7 maxlength=7>

It's just this simple.

In playing around to try to find the problem, I found that if I put two text boxes it solved the problem.

<input type=text size=7 maxlength=7>
<input type=text size=7 maxlength=7>

Just in case that's a clue.

Thank you,

Puzzled Peter

jmrker
10-28-2006, 02:24 PM
I don't think putting in an extra text box makes any difference.

In order for you textbox to do anything when you "ENTER"
you must tell it to do something. Here is an example:



<html>
<head>
<title>Enter Test</title>
</head>
<body>
<form onSubmit="return false">
Enter something here:
<input type="text" value="" onChange="alert(this.value)">
</body>
</html>

Your posted textbox just sits there!
Hope this helps.

peterinwa
10-28-2006, 05:30 PM
I use onChange in all my text boxes on all my pages including this text box and it works just great. This text box works just as I want it to.

The problem is that I just hit Enter out of curiosity to see what would happen. In all my other text boxes nothing happens except in Internet Explorer the browser makes a ping.

In this one text box... and it's the only page I have with only one text box on it come to think of it... it causes the page to reload.

I removed onChange just to be sure that wasn't causing the problem.

I put another text box beside it to see if it had the same problem, and that's when I discovered that with two text boxes the problem goes away!

It's either something messed up with my code on this page, or it's a problem with all my pages but for some odd reason I don't see it on other pages because they have more than one text box.

Thanks, Peter

brandonH
10-29-2006, 11:22 AM
please post your code, it'll help us if we can see and filter through it.

the problem definity sounds weird. I have never encountered that problem myself.

try using the onkeyup method and setting it to "return false;"
that should stop any bubbling up to the window.

peterinwa
10-29-2006, 04:45 PM
I think posting the code is prohibitive because my calculator pages are so complex and include so many other .js files with other coding. But I'll e-mail you the page so you can see it just for fun.

If the problem doesn't go away I can try your work-around. However, I'm going to be converting British Stones and Pounds and will need two boxes... so the problem just may go away!

Thanks, Peter



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum