I'm new to knockout and javascript. I want to create input value on input box and that value print out on document.write
but kotext
value is not updating on testText
and changing the value on input box. I want keep print out the value to document.write
and array push(textKo)
process.
Source :
<head>
<script src="knockout-3.1.0.js"></script>
</head>
<body>
<div class="sidebar">
<div class="line">
<label>1st Object Name</label>
<input type="text" data-bind="value: kotext1" />
<input type="text" data-bind="value: kotext2" />
<input type="text" data-bind="value: kotext3" />
</div>
</div>
<script>
var AppViewModel = function(){
kotext1 = ko.observable("No.1!");
kotext2 = ko.observable("No.2!");
kotext3 = ko.observable("No.3!");
}
ko.applyBindings(AppViewModel);
testText = function(val) {
return "This is " + val;
}
textKo = [testText(kotext1()),testText(kotext2()),testText(kotext3())];
document.write(textKo);
</script>