Page 92 - TP_Play_V2.1_class8
P. 92
Adding DataList
To provide input suggestions while allowing the user to submit input directly, use the <datalist>
element.
The <datalist> element provides a list of options for the user to select from, but it also allows the
user to enter their own input freely in an associated <input> field.
To add the data list in the form, follow the syntax as given below:
<INPUT LIST="list type" NAME="name of the list">
<DATALIST ID="Id of list">
<OPTION VALUE="Option1">
<OPTION VALUE="Option2">
<OPTION VALUE="Option3">
<OPTION VALUE="Option4">
</DATALIST>
For example:
<INPUT LIST="Countries" NAME="Country">
<DATALIST ID="Countries">
<OPTION VALUE="India">
<OPTION VALUE="China">
<OPTION VALUE="Indonesia">
<OPTION VALUE="Pakistan">
<OPTION VALUE="Bangladesh">
<OPTION VALUE="Japan">
</DATALIST>
The above code will create a drop-down list in which these countries names are available.
Let us create a web page to display the datalist.
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>Countries</TITLE>
</HEAD>
<BODY>
<FORM>
Choose Your Country:
<INPUT LIST="Countries" NAME="Country">
90 Play (Ver. 2.1)-VIII

