Perform math on dynamically updating javascript Value -


i have figured out how update html dynamically based on current input of form. however, stumped how perform math on value (ie value*5), , display result, instead of merely displaying value in form.

here live example: https://dl.dropboxusercontent.com/u/14749627/happy2/number.html

here javascript:

<script> window.onload = function() {  var purchase_quantity = document.getelementbyid('purchase_quantity'); purchase_quantity.onclick = updatenamedisplay; purchase_quantity.onclick = updatenamedisplay; purchase_quantity.onclick = updatenamedisplay; function updatenamedisplay() {   document.getelementbyid('namedisplay').innerhtml = this.value || "1";  } }; </script> 

campari's solution works, should convert number explicitly habit. if tried add instead, wouldn't work expected. also, oriol pointing out other problem.

var purchase_quantity = document.getelementbyid('purchase_quantity'); purchase_quantity.onclick = updatenamedisplay;  function updatenamedisplay() {     document.getelementbyid('namedisplay').innerhtml =          this.value.length ? number(this.value) * 5 : "1"; } 

demo


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -