Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Vancouver, WA
    Posts
    233
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Enter Key in Text Box

    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

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,065
    Thanks
    36
    Thanked 497 Times in 491 Posts
    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:

    PHP Code:
    <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.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Vancouver, WA
    Posts
    233
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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

  • #4
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    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.
    Last edited by brandonH; 10-29-2006 at 11:25 AM. Reason: correction
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Vancouver, WA
    Posts
    233
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •