script.aculo.us Autocompleter Frequency Option

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>w3wiki</h1>
    <label for="w3wiki">
        Input any name:
    </label>
 
    <br>
    <input id="w3wiki" 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(
            'w3wiki',
            '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>w3wiki</h1>
 
    <label for="w3wiki">
        Input any name:
    </label>
    <br>
     
    <input id="w3wiki" 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(
            'w3wiki',
            'names',
            names,
            { frequency: .1 }
        );
    </script>
</body>
 
</html>


Output:



Contact Us