-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathform.html
53 lines (49 loc) · 1.23 KB
/
form.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Emit Value</title>
<style>
label {
display: inline-block;
width: 4em;
margin-right: 1em;
}
input, output {
width: 8em;
}
</style>
</head>
<body>
<h2>Emit value</h2>
<form onsubmit="return false">
<label for="first">First:</label>
<input type="number" id="first">
<br>
<label for="second">Second:</label>
<input type="number" id="second">
<br>
<label for="third">Third:</label>
<input type="number" id="third">
<br>
<label for="result">Result:</label>
<output id="result"/>
</form>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="js/emit.js"></script>
<script>
'use strict';
var inputs = $('input');
var result = $('output')
Emit.sequence(inputs)
.map(Emit.input)
.combine(inputs.length)
.map(function (values) {
return values.reduce(function (r, v) {
return r + Number(v);
}, 0);
})
.forEach(result.val.bind(result));
</script>
</body>
</html>