forked from mfranzke/datalist-polyfill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
244 lines (205 loc) · 7.47 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<!DOCTYPE html>
<html lang="en">
<head>
<title>datalist polyfill demo</title>
<style>
/**
* Add the correct display in IE 10-.
* Adapted out of https://github.com/necolas/normalize.css/
*/
[hidden] {
display: none;
}
/* these are demo related styles */
input[type="email"] {
width: 400px;
}
</style>
</head>
<body>
<h2>Basis</h2>
<fieldset>
<legend>What's your favorite animal</legend>
<label for="animal">Animal:</label>
<input type="text" name="animal" id="animal" value="" list="animallist">
<datalist id="animallist" title="Choose a suggestion">
<option value="Cat">
<option value="Cow">
<option value="Dog">
<option value="Horse">
<option value="Lion">
<option value="Pig" disabled>
<option value="Zebra">
</datalist>
</fieldset>
<h2>Right to left</h2>
<fieldset dir="rtl">
<legend>What's your favorite animal</legend>
<label for="animal2">Animal:</label>
<input type="text" name="animal2" id="animal2" value="" list="animallist2">
<datalist id="animallist2" title="Suggestions to choose from">
<option value="Cat">
<option value="Cow">
<option value="Dog">
<option value="Horse">
<option value="Lion">
<option value="Pig" disabled>
<option value="Zebra">
</datalist>
</fieldset>
<h2>Internet Explorer 9 support</h2>
<fieldset>
<legend>What's your favorite animal</legend>
<label for="animal_ie">Animal:</label>
<input type="text" name="animal_ie" id="animal_ie" value="" list="animallist_ie">
<datalist id="animallist_ie" title="Choose a suggestion">
<!--[if IE 9]><select disabled style="display:none" class="ie9_fix"><![endif]-->
<option value="Cat">
<option value="Cow">
<option value="Dog">
<option value="Horse">
<option value="Lion">
<option value="Pig" disabled>
<option value="Zebra">
<!--[if IE 9]></select><![endif]-->
</datalist>
<p>Thanks to @Kravimir for mentioning the main IE9s problem (that is additionally outlined here: <a href="https://stackoverflow.com/questions/12394512/get-datalist-options-in-ie9-with-javascript">https://stackoverflow.com/questions/12394512/get-datalist-options-in-ie9-with-javascript</a>), that could be solved by wrapping the <code>option</code> elements:</p>
<code>
<datalist id="animallist" title="Choose a suggestion"><br>
<strong><!--[if IE 9]><select disabled style="display:none" class="ie9_fix"><![endif]--></strong><br>
<option value="Cat"><br>
<option value="Cow"><br>
<option value="Dog"><br>
<option value="Horse"><br>
<option value="Lion"><br>
<option value="Pig" disabled><br>
<option value="Zebra"><br>
<strong><!--[if IE 9]></select><![endif]--></strong><br>
</datalist>
</code>
</fieldset>
<h2>Advanced</h2>
<h3>Different ways of defining an option</h3>
<fieldset>
<legend>Choose an option</legend>
<code>
<option value="option 1"><br>
<option>option 2</option><br>
<option value="option value 3">option label 3</option><br>
<option value="option value 4" label="option label 4">
</code>
<p>thank you @aFarkas for your great overview: <a href="https://github.com/h5bp/html5please/issues/18">https://github.com/h5bp/html5please/issues/18</a></p>
<label for="animal">Options:</label>
<input type="text" name="options" id="options" value="" list="optionlist">
<datalist id="optionlist" title="Choose an option">
<option value="option 1">
<option>option 2</option>
<option value="option value 3">option label 3</option>
<option value="option value 4" label="option label 4">
</datalist>
</fieldset>
<h3>Input type email</h3>
<fieldset>
<legend>Whom you'd like to reach out to</legend>
<label for="email">Email address(es):</label>
<input type="email" name="email" id="email" value="" list="emaillist" multiple>
<datalist id="emaillist" title="Email addresses suggestions:">
<option value="[email protected]">
<option value="john@doe">
<option value="[email protected]" disabled>
<option value="[email protected]">
<option value="[email protected]">
</datalist>
</fieldset>
<h3>Input type number (with a bigger amount of options)</h3>
<fieldset>
<legend>Choose a number wisely</legend>
<label for="number">Number:</label>
<input type="number" name="number" id="number" value="" list="numberlist" multiple>
<datalist id="numberlist" title="Number suggestions:">
<option value="1">
<option value="2">
<option value="3">
<option value="5">
<option value="8">
<option value="13">
<option value="20">
<option value="40">
<option value="42">
<option value="100">
<option value="101">
<option value="102">
<option value="103">
<option value="104">
<option value="105">
<option value="106">
<option value="107">
<option value="108">
<option value="109">
<option value="110">
<option value="111">
<option value="112">
<option value="113">
<option value="114">
<option value="115">
<option value="116">
<option value="117">
<option value="118">
<option value="119">
<option value="120">
<option value="130">
<option value="140">
<option value="150">
<option value="200">
<option value="300">
<option value="400">
<option value="500">
<option value="1000">
</datalist>
</fieldset>
<h3>Input type search</h3>
<fieldset>
<legend>Please provide a search term</legend>
<label for="search">Search:</label>
<input type="search" name="search" id="search" value="" list="searchlist" multiple>
<datalist id="searchlist" title="Search suggestions:">
<option value="weather">
<option value="translate">
<option value="maps">
<option value="news">
<option value="calculator">
<option value="g">
<option value="youtube to mp3">
<option value="dictionary">
<option value="f">
<option value="translator">
</datalist>
</fieldset>
<h3>Input type tel</h3>
<fieldset>
<legend>Who you gonna call?</legend>
<label for="tel">Telephone no.:</label>
<input type="tel" name="tel" id="tel" value="" list="tellist" multiple>
<datalist id="tellist" title="Telephone no. suggestions:">
<option value="555-2323">
<option value="91-1892-221343">
<option value="206-709-3100">
<option value="44-020-7930-4832">
<option value="39-06-6982">
<option value="202-456-1111">
</datalist>
</fieldset>
<h3>Input type url</h3>
<fieldset>
<legend>What's your favorite website</legend>
<label for="url">URLs:</label>
<input type="url" name="url" id="url" value="" list="urllist" multiple>
<datalist id="urllist" title="URL suggestions:">
<option value="https://davidhasselhoffonline.com">
<option value="https://southpark.cc.com">
<option value="https://reynholm.co.uk">
</datalist>
</fieldset>
<script type="text/javascript" src="datalist-polyfill.js"></script>
</body>
</html>