please anybody help to solve keydown event for enter button problem

Discussion in 'JavaScript' started by Ravikumar, Mar 8, 2007.

  1. #1
    Hi,


    I am working in asp.net with C# web application, i have used one textbox and image button for search funtion, i have created one user control for this, but problem is after i have entered value in textbox when i have pressed the enter button, its not at all working, if i will use mouse i can able to search values, how to enable to enter key at keydown event of textbox, the following script i have used ,


    function Buttonfocus()
    {
    if(event.which || event.keyCode)
    {
    if ((event.which == 13) || (event.keyCode == 13) || (event.which == 10) || (event.keyCode == 10))
    {
    document.getElementById("go").click();
    return false;
    }
    }
    else
    {
    return true;
    }
    }

    Please anybody to help me solve this problem in my application, advanced thanks for any reply.

    Thanks.
     
    Ravikumar, Mar 8, 2007 IP
  2. Aragorn

    Aragorn Peon

    Messages:
    1,491
    Likes Received:
    72
    Best Answers:
    1
    Trophy Points:
    0
    #2
    As far as I know, there is no standard method named click. I think Opera supports this method, but no other browsers support this.

    If all you want to do is submit the form, then you can use the following line

    
    document.forms['[b]form_name_here[/b]'].submit()
    
    Code (markup):
    instead of
    document.getElementById("go").click();
    Code (markup):
    Are you sure that the following is not the code that you actually want?
    <input type='text' name='query' /><input type='image' src='go_button.gif' name='go' />
    Code (markup):
     
    Aragorn, Mar 8, 2007 IP