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 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Cant use enter?????

    Hi

    I am using a very simple search-type page to enable users to input a model number and its page appears in a inline frame. Its not a true search as it is simply relying on a person entering the correct html page name to find it. But this works perfectly in my application.

    The problem I have is that I cannot get the type box to accept enter key as a submitt, only a click of the mouse will submitt the request. If enter is pressed the box loses the users input but no action is taken.

    I think this may be a javascript issue. I have posted the code below.

    Can anyone help?

    [CODE]
    <html>
    <head>
    <script language=javascript >

    function changeF(url) {
    parent.frames['I1'].location.href = url + ".htm"
    }
    </script>
    </head>

    <body>
    <BODY>

    <form name="form1" method="get">
    <p align="right">
    <input type="input" name="test" value="" alt="Please use lower case and no spaces in your search. use simple terms such as motor, pump, d661 etc etc">
    <input type="submit" name="hi" value="Search By Model Name" onclick="changeF(document.form1.test.value)">
    <img src="images/info-symbol.gif" width="23" height="22" alt="Please use lower case only, and keep search terms simple. e.g. pump or g761">&nbsp; or use the drop down menu</p>
    </form>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </body>
    </html>
    [CODE]

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Try this:-

    Code:
    <html>
    <head>
    
    <script type = "text/javascript">
    function changeF(url) {
    parent.frames['I1'].location.href = url + ".htm"
    }
    
    function chk13() {
    if ((event.which && event.which == 13) ||(event.keyCode && event.keyCode == 13)) {
    document.form1.hi.click();
    return true;
    } 
    else {return false}
    }
    </script>
    </head>
    
    <body>
    
    <form name="form1" method="get">
    <p align="right">
    <input type="input" name="test" value="" alt="Please use lower case and no spaces in your search. use simple terms such as motor, pump, d661 etc etc"  onkeydown="chk13()">
    
    <input type="submit" name="hi" value="Search By Model Name" onclick="changeF(document.form1.test.value)">
    <img src="images/info-symbol.gif" width="23" height="22" alt="Please use lower case only, and keep search terms simple. e.g. pump or g761">&nbsp; or use the drop down menu</p>
    
    </form>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </body>
    </html>

    BTW, your closing code tag should read [/code]

    "I like long walks, especially when they are taken by people who annoy me." - Noel Coward

  • #3
    New Coder
    Join Date
    Feb 2009
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Many Thanks

    Hi Philip M

    Many thanks for your help this works perfectly.

    All the best

    Graham


  •  

    Posting Permissions

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