Skip to content
Related Articles

Related Articles

Improve Article

script.aculo.us Autocompleter Frequency Option

  • Last Updated : 20 Nov, 2020

The local array autocompleter is used when you’d prefer to inject an array of autocompletion options into the page, the array is used to apply the autocomplete functionality on your page.

Autocompleter Frequency Option: The frequency option determines how frequently (in seconds) the input field auto completion suggestions should be refreshed for changes before firing an Ajax request.

Syntax:

{ frequency: seconds }

Values:

  • seconds: This is a float value. The default value is 0.4.

Example 1: In this example, we have set the frequency option to 3s, so it will take 3s to update the recommendations.



HTML




<!DOCTYPE html>
<html>
 
<head>
    <script type="text/javascript"
        src="javascript\prototype.js">
    </script>
 
    <script type="text/javascript" src=
"javascript/scriptaculous.js?load = effects,controls">
    </script>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <label for="GeeksforGeeks">
        Input any name:
    </label>
 
    <br>
    <input id="GeeksforGeeks" autocomplete="off"
        size="40" type="text" value="" />
     
    <div class="autocomplete" id="names"
        style="display:none">
    </div>
     
    <script type="text/javascript">
 
        var names = [
            'Ab gfg',
            'Abc gfg',
            'Abcd gfg',
            'Abcde gfg',
            'Abcdef gfg',
            'Abcdefg gfg',
            'Abcdefgh gfg'
        ];
 
        new Autocompleter.Local(
            'GeeksforGeeks',
            'names',
            names,
            { frequency: 3 }
        );
    </script>
</body>
 
</html>

Output:

Example 2: In this example, we have set the frequency option to .1s, so it will take .1s to update the recommendations.

HTML




<!DOCTYPE html>
<html>
 
<head>
    <script type="text/javascript"
        src="javascript\prototype.js">
    </script>
     
    <script type="text/javascript" src="
javascript/scriptaculous.js?load = effects,controls">
    </script>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
 
    <label for="GeeksforGeeks">
        Input any name:
    </label>
    <br>
     
    <input id="GeeksforGeeks" autocomplete="off"
        size="40" type="text" value="" />
 
    <div class="autocomplete" id="names"
        style="display:none">
    </div>
     
    <script type="text/javascript">
 
        var names = [
            'Ab gfg',
            'Abc gfg',
            'Abcd gfg',
            'Abcde gfg',
            'Abcdef gfg',
            'Abcdefg gfg',
            'Abcdefgh gfg'
        ];
 
        new Autocompleter.Local(
            'GeeksforGeeks',
            'names',
            names,
            { frequency: .1 }
        );
    </script>
</body>
 
</html>

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :