Web Analytics Made Easy -
StatCounter Automatic Search - CodingForum

Announcement

Collapse
No announcement yet.

Automatic Search

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automatic Search

    I'm looking for a way to submit a search form if the user has stopped typing for say, 1 second.

    I tried using setTimeout onkeyup, but of course, that starts running as soon as the first key is pressed, and therefore searches 1 second after that...

    <input type="text" onkeyup="runTimer()" name="s" id="s" />
    markaylward.co.uk

  • #2
    onkeydown = "cancelTimer()"

    Pity the chap who pauses to sneeze while typing his search terms in!

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

    Comment


    • #3
      Thanks. How can I actually stop/start a timer though? Not very good with Javascript!

      It's just a test for now, based pretty much on live searches.
      markaylward.co.uk

      Comment


      • #4
        function runTimer() {
        x = setTimeout ("runTimer()", 1000); /// 1 second delay
        }

        onkeyup = "runTimer()"

        onkeydown = "clearTimeout(x)"

        See also http://www.codingforum.net/showthread.php?t=95823
        Last edited by Philip M; Sep 24, 2006, 02:18 PM.

        All the code given in this post has been tested and is intended to address the question asked.
        Unless stated otherwise it is not just a demonstration.

        Comment

        Working...
        X