title: JS change input value
body: <p>My problem is:
  I have two input boxes one for a code and one for a price:</p>
  
  <pre><code>&lt;input class="style" name="code" id="code" type="text"&gt;
  &lt;input class="style" name="price" id= "price" type="text" value="&amp;euro; 15,00" readonly="readonly"&gt;
  </code></pre>
  
  <p>Now i want to change the price by code (like a check from a code array [code1][code2]. result to code1 = price/2 and code2 = price/4 ) This i want to check by a script in real time or befor the post (on submit). This this possible when yes how? Or is there another better way to do this ?</p>
  
  <p>I have:</p>
  
  <pre><code>while(true) 
  {
      var code = document.getElementById("code").value;
  
      var codes = new Array("promo1", "promo2");
  
      for (var i=0; i&lt;codes.length; i++) {
  
          if (codes[i] == code) {
              document.getElementById("price").value = "5";
          }       
      }
  }
  </code></pre>
  
  <p>and my input fields are obviously in a form-field
  but the value doesnt change, but why ? 
  I dont have to change in real time it would be ok if the post sends the new value...any solutions/better ideas/hints ?
  I know there is JQuery a better approach but it shouldn't be a problem with js.</p>
  
  <p>fiddle link:<br>
  <a href="http://jsfiddle.net/vicR/4Mtbr" rel="nofollow">jsfiddle.net/vicR/4Mtbr</a></p>