title: adding values from input field to observableArray and display it (knockout.js)
body: <p>This is my first attempt at some knockout.js. There is an input field and the value you write into it gets "sent" to a list and displayed. However, it doesnt work and I guess it has to do with the fact that this.prodname is not associated correclty to the observableArray. But I cant figure out how to do that.</p>
  
  <p>My code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;script type="text/javascript" src="jquery-1.10.2.min.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="knockout-3.0.0.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="app.js"&gt;&lt;/script&gt;
          &lt;link rel="stylesheet" type="text/css" href="lt.css"/&gt;
          &lt;title&gt;eins&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id="main"&gt;
          &lt;form data-bind="submit:addValues"&gt;
              &lt;input type="text" data-bind="value:newprod, valueUpdate='afterkeydown'"&gt;&lt;/input&gt;
              &lt;input type="text" data-bind="value:number,valueUpdate='afterkeydown'"&gt;&lt;/input&gt;
              &lt;button type="submit"&gt;OK&lt;/button&gt;
          &lt;/form&gt;
              &lt;ul data-bind="foreach:productname"&gt;
              &lt;li data-bind="text : $index"&gt;&lt;/li&gt;
                  &lt;li data-bind="text:prodname"&gt;&lt;/li&gt;
                  &lt;li data-bind="text:anzahl"&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And app.js</p>
  
  <pre><code>$(document).ready(function () {
  
      var mymodel = function() {
  
          this.newprod = ko.observable("");
          this.productname = ko.observableArray(""):
  
          this.addValues = function() {
              this.productname.push(this.newprod());
          };
  
      };
      ko.applyBindings(new mymodel());
  });
  </code></pre>
  
  <p>I tried this, too:</p>
  
  <pre><code>this.productname.push({newprod: this.newprod() });
  </code></pre>
  
  <p>After reading this post: <a href="https://stackoverflow.com/questions/19419438/adding-an-item-to-an-observablearray-in-knockoutjs-when-using-mapping">https://stackoverflow.com/questions/19419438/adding-an-item-to-an-observablearray-in-knockoutjs-when-using-mapping</a></p>
  
  <p>As far as I can tell, my code resembles this example:
  <a href="http://knockoutjs.com/examples/betterList.html" rel="nofollow">http://knockoutjs.com/examples/betterList.html</a></p>
  
  <p>However, I dont want the observableArray to be prepopulated. I want the values to come from the input field.</p>
  
  <p>Thanx for your help!</p>