Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptscript.aculo.us Autocompleter tokens Option

script.aculo.us Autocompleter tokens Option

In this article, we will show the effect of Autocompleter Tokens by using JavaScript library named as script.aculo.us, which helps to autocomplete the text fields according to the given suggestions in the form of an array. We can add a list of suggestions as well.

Please refer to script.aculo.us to download libraries or pre-compiled files for implementation. Also, take care of proper file paths otherwise the code will not work.

Syntax:

new Autocompleter.Local(field, container, dataSource [ , options ] );

Parameters:

  • field: Element name of the text field.
  • container: Container element name which gives suggestions.
  • datasource: Data source can be a single text or array of strings.

Demonstration: In this example, we have used the function in HTML code. We have written a small JavaScript function that runs when the windows load and use the Autocompleter Tokens method of this library. By typing anything in the search box we can get the suggestions.

To see the effect, first, install the library and then open this program in the local environment.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script type="text/javascript" 
        src="prototype.js">
    </script>
  
    <script type="text/javascript" 
        src="scriptaculous.js?load = effects">
    </script>
  
    <script type="text/javascript">
        window.onload = function () {
            new Autocompleter.Local(
                'autoCompleteTextField',
                'autoCompleteList',
                ['abcxyz', 'bcdmnop', 'neveropen', 
                'neveropenfor', 'neveropen'],
                { ignoreCase: false }
            );
        }
    </script>
</head>
  
<body>
    <h3>Welcome to GeeksForGeeks</h3>
  
    <p>
        You can type anything and 
        get the suggestions
    </p>
  
    <div>
        <label>Search:</label>
        <input type="text" id="autoCompleteTextField" />
        <div id="autoCompleteList"></div>
    </div>
</body>
  
</html>


Output:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments