Тег input, атрибут list

List

The list input allows you to structure data from child inputs as an array. The list itself outputs no markup (by default) and can be used in conjunction with any other type of input — including nested groups and lists.

The value of a list input is an array where each item is the value of the input at that index. Sub-inputs do not need to be of the same type. In addition to structuring data, lists can determine the validation state, provide initial values, and supply plugins and configuration to all of its children.

Basic example

Vue’s handy v-model is fully supported in FormKit with bi-directional data flow even on lists and groups. However, if your form needs extremely high performance consider using the core node to read/write instead of v-model.

List types

There are 2 flavors of lists:

  • Static lists (default) have pre-determined children. They should not be used for iterating over values or adding/removing items.
  • Dynamic lists allow iteration over the list’s value to create its children. They are useful for creating dynamic-length lists like repeaters.
Читайте также:  Obfuscation in java code

Static lists

Static lists are the simplest type of list to create. Wrap any inputs in a and those inputs will automatically be set as values of their array. Immediate children of lists do not have a name (even if specified) instead they are always identified by their index. In a static list, this index is stable and is based on the order of the inputs.

Static lists should not be used for iterating over their own value. While it is safe to iterate over other arbitrary data iterating over the value of the list itself will cause recursive rendering and infinite loops. Instead use a dynamic list.

Dynamic lists

Dynamic lists allow you to iterate over the values of the list to create and hydrate the inputs inside the list. Dynamic lists are useful for creating dynamic array structures like repeaters.

You can mutate the structure of your dynamic list by adding and removing items from the value array. FormKit will automatically update the underlying form structure to match the new value.

In order for dynamic lists to keep your data in sync, you must use items from the default slot to create your v-for and you must also pass the index of the v-for as the index prop to each item in of the list.

To use a prebuilt repeater, check out the free FormKit Pro repeater input .

Источник

Атрибут list

Указывает на список вариантов, созданный с помощью тега , которые можно выбирать при наборе текста. Изначально этот список скрыт и становится доступным при получении полем фокуса.

Синтаксис

Значение

       

Аперитивы

Вид текстового поля при наборе текста показан на рис. 1.

Рис. 1. Выбор текста из списка

Не выкладывайте свой код напрямую в комментариях, он отображается некорректно. Воспользуйтесь сервисом cssdeck.com или jsfiddle.net, сохраните код и в комментариях дайте на него ссылку. Так и результат сразу увидят.

Типы тегов

HTML5

Блочные элементы

Строчные элементы

Универсальные элементы

Нестандартные теги

Осуждаемые теги

Видео

Документ

Звук

Изображения

Объекты

Скрипты

Списки

Ссылки

Таблицы

Текст

Форматирование

Формы

Фреймы

Источник

HTML Form Elements

This chapter describes all the different HTML form elements.

The HTML Elements

The HTML element can contain one or more of the following form elements:

The Element

One of the most used form element is the element.

The element can be displayed in several ways, depending on the type attribute.

Example

All the different values of the type attribute are covered in the next chapter: HTML Input Types.

The Element

The element defines a label for several form elements.

The element is useful for screen-reader users, because the screen-reader will read out loud the label when the user focus on the input element.

The element also help users who have difficulty clicking on very small regions (such as radio buttons or checkboxes) — because when the user clicks the text within the element, it toggles the radio button/checkbox.

The for attribute of the tag should be equal to the id attribute of the element to bind them together.

The Element

The element defines a drop-down list:

Example

The elements defines an option that can be selected.

By default, the first item in the drop-down list is selected.

To define a pre-selected option, add the selected attribute to the option:

Example

Visible Values:

Use the size attribute to specify the number of visible values:

Example

Allow Multiple Selections:

Use the multiple attribute to allow the user to select more than one value:

Example

The Element

The element defines a multi-line input field (a text area):

Example

The rows attribute specifies the visible number of lines in a text area.

The cols attribute specifies the visible width of a text area.

This is how the HTML code above will be displayed in a browser:

You can also define the size of the text area by using CSS:

Example

The Element

The element defines a clickable button:

Example

This is how the HTML code above will be displayed in a browser:

Note: Always specify the type attribute for the button element. Different browsers may use different default types for the button element.

The and Elements

The element is used to group related data in a form.

The element defines a caption for the element.

Example

This is how the HTML code above will be displayed in a browser:

The Element

The element specifies a list of pre-defined options for an element.

Users will see a drop-down list of the pre-defined options as they input data.

The list attribute of the element, must refer to the id attribute of the element.

Example

The Element

The element represents the result of a calculation (like one performed by a script).

Example

Perform a calculation and show the result in an element:

HTML Exercises

HTML Form Elements

Tag Description
Defines an HTML form for user input
Defines an input control
Defines a multiline input control (text area)
Defines a label for an element
Groups related elements in a form
Defines a caption for a element
Defines a drop-down list
Defines a group of related options in a drop-down list
Defines an option in a drop-down list
Defines a clickable button
Specifies a list of pre-defined options for input controls
Defines the result of a calculation

For a complete list of all available HTML tags, visit our HTML Tag Reference.

Источник

HTML list Attribute

An element with pre-defined values in a :

Definition and Usage

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Attribute
list 20.0 10.0 4.0 Not supported 9.6

Syntax

Attribute Values

Unlock Full Access 50% off

COLOR PICKER

colorpicker

Join our Bootcamp!

Report Error

If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:

Thank You For Helping Us!

Your message has been sent to W3Schools.

Top Tutorials
Top References
Top Examples
Get Certified

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Источник

Оцените статью