このページのトップへ
国のオートコンプリート

国のオートコンプリート

入力中に自動的に国名を補完します。キーボードを使用して、必要な国を選択します。

中級.png

中級

3K

出版された:

June 22, 2021

酒を楽しむ少女

によって

アンカー 1
開発者を雇う

説明例

In this example, we created a collection named Countries, which stores a list of country names. When the site visitor starts typing in the country field, suggestions for country names that have the same prefix as the characters the visitor typed are displayed using a repeater. The site visitor can either continue typing or choose his country using the keyboard or the mouse.

コード例

タブ1

.

タブ2

.

タブ3

.

このコードによる解決は複雑になる可能性がある。

どのように構築したか


ページ要素


We added the following elements:


  • 3 text input elements: name, email and country.

  • Repeater: for displaying the country name suggestions.

  • Submit button: for submitting the form.



ページコード


First we declare some constant values, such as the colors of the repeater’s items and the maximum number of items to be displayed.


We also manage 3 global variables:


  • listSize: the amount of currently displayed items in the list.

  • currIndex: the index of the current selected item in the repeater.

  • debounceTimer: helps to provide smoother behavior for the search functionality.


When the site visitor starts typing in the country input element, we send a query to the Countries collection. This query finds the country names that start with the current input value. Those countries are displayed in the repeater, with each country in its own repeater item. Using the keyboard arrow keys, the user can navigate up and down the repeater items and select a country by pressing the Enter key. The country menu can be closed by pressing the Esc key. Visitors can also use the mouse. When one navigates to an item using the keyboard arrows, that item’s color changes to indicate it will be selected if the Enter key is pressed.



When the visitor clicks the Send button, the form is submitted to another database collection.

使用したAPI

コード以外の例。

コード以外の例。

コード以外の例。

関連記事

記事リンク

開発者を雇う

Veloソリューションは強力なツールですが、自力で構築するのは困難です。経験豊富なVelo開発会社に構築をお任せください。

関連例

これは役に立ったか?

はい

|

いいえ

ご意見ありがとう!

City Weather

City Weather

Get weather information according to city

中級.png

中級

ページの状態を維持する

ページの状態を維持する

動的なページに移動している間、リピーターの状態を維持する。

中級.png

中級

クイズの作成

クイズの作成

データベースコレクションからランダムに問題を選択するクイズを作成します。

中級.png

中級

アンカー2
ページ下