-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput.html
49 lines (45 loc) · 1.29 KB
/
input.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
<!doctype html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="css/playground.css">
<script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>
</head>
<body>
<h2>form</h2>
<p class="formLayout">
<label for="title_small">Title small</label>
<input type="text" id="title_small" class="master" placeholder="Type here"></input>
<br>
<label for="title_medium">Title medium</label>
<input type="text" id="title_medium" class="slave"></input>
<br>
<label for="title_long">Title long</label>
<input type="text" id="title_long" class="slave"></input>
<br>
<input type="button" value="save">
</p>
<script>
YUI().use('node', function (Y) {
Y.one('.master').after('keyup', function(e){
Y.all('.slave').set('placeholder',e.target.get('value'));
});
Y.one('input[value="save"]').on('click', function(e){
var result = {};
Y.all('input[type="text"]').each(function(node,b,c){
var field = {};
if(node.get('value') != ""){
field.value = node.get('value');
field.userdefined = true;
} else {
field.value = node.get('placeholder');
field.userdefined = false;
}
result[node.get('id')] = field;
});
console.log(result);
})
});
</script>
</body>
</html>