Onclick="Enter" with my code

Discussion in 'JavaScript' started by BRIAN_C_C, Sep 25, 2007.

  1. #1
    I'd like to add the "enter" function to this... anyone know how?

    <form><input name='search_term'>&nbsp;&nbsp;&nbsp;&nbsp;<input
    type='button' value="Search" onclick=
    "javascript:find_text(search_term.value);"></form>
    
    Code (markup):
    Here's the code....

    <script type="text/javascript">
    function find_text(txt) {
    var rng = document.body.createTextRange()
    if (rng.findText(txt)) {
    rng.select();
    }
    }
    </script>
     
    BRIAN_C_C, Sep 25, 2007 IP
  2. Awanish

    Awanish Peon

    Messages:
    53
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    make your button as type=submit, and the enter key will start working.
     
    Awanish, Sep 26, 2007 IP
    BRIAN_C_C likes this.
  3. BRIAN_C_C

    BRIAN_C_C Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you... I found another search option!
     
    BRIAN_C_C, Oct 2, 2007 IP