-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
71 lines (55 loc) · 1.9 KB
/
index.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
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<title>Dynamic TextFields</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="./textfields.css">
<style>
html {
background-color: #F5F5F5;
}
body {
margin: 20px auto;
width: 100%;
max-width: 800px;
color: #303030;
background-color: #fff;
padding: 50px;
font-family: "Source Sans Pro", Helvetica, sans-serif;
}
</style>
</head>
<body>
<div id="the-container">
<div class="dyn-textfield">
<input type="text" class="dyn-textfield-input" id="one" onkeyup="document.getElementById('three').value = this.value">
<label for="one" class="dyn-textfield-label">Label for One</label>
</div>
<br>
<div class="dyn-textfield">
<input type="text" class="dyn-textfield-input" id="two" value="something">
<label for="two" class="dyn-textfield-label">Label for Two</label>
</div>
<br>
<div>This field’s value changes when the first one’s changes:</div>
<div class="dyn-textfield">
<input type="text" class="dyn-textfield-input" id="three">
<label for="three" class="dyn-textfield-label">Label for Three</label>
</div>
</div>
<script type="module">
import DynamicTextFields from "./textfields.js";
// Construct the object of the element that contains all of the text fields that you want to style.
let tf = new DynamicTextFields("the-container");
// Copy object to window for access in the console (for the example only).
window.tf = tf;
// Register all of the text fields within the container.
tf.registerAll();
// Reset the styling because we are starting with a text field that already has text inside.
tf.resetAllStyles();
// Register a refresher: When the text field with id="one" changes, update the style of the text field
// with id="three".
tf.registerRefresher("one", "three");
</script>
</body>
</html>