-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforms.html
More file actions
50 lines (45 loc) · 1.46 KB
/
forms.html
File metadata and controls
50 lines (45 loc) · 1.46 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sample Knockoutjs App</title>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
</head>
<body>
<p data-bind="text:submission">Results</p>
<form data-bind="submit:showData">
<input type="text" data-bind="textInput:name"/><br>
<select data-bind="options: optionValues, value: selectedOptionValue"></select><br>
<textarea data-bind="value:message"></textarea><br>
<input type="checkbox" data-bind="checked: rememberMe" /> Remember me<br>
<button type="submit">Submit</button>
</form>
<script type='text/javascript' src='./js/knockout-3.5.0.js'></script>
<script>
function View(){
var self = this;
this.submission = ko.observable("Results:");
this.name = ko.observable('');
this.optionValues= ["Alpha", "Beta", "Gamma"];
this.selectedOptionValue = ko.observable("Gamma");
this.message = ko.observable("");
this.rememberMe = ko.observable(true);
this.showData = function(form){
var data = {
name : self.name(),
rays : self.selectedOptionValue(),
message : self.message(),
rememberMe : self.rememberMe()
};
$.post('url', data, function(){
});
console.log(data);
}
}
ko.applyBindings(new View());
</script>
</body>
</html>