Javascript Summation -


i'm attempting create autosummation tool not count blank cells. it's counting 1, count more later. returns nan number entry.

var _num1 = document.getelementbyid('num1'); var _sum  = document.getelementbyid('sum');  _num1.onblur = function summation(){     _sum.value = 0;     _sum.value = (parseint(_sum.value,10) + (isnan(_num1) ? 0 : _num1.value)); }; 

html

num 1: <input type="text" id="num1" name="num1" value=""><br/> sum:  <input type="text" id="sum"  name="sum" value=""> 

please try this:

var _num1 = document.getelementbyid('num1'); var _sum  = document.getelementbyid('sum');  _num1.onblur = function summation(){     _sum.value = 0;      var num1 = parseint(_num1.value, 10);     _sum.value = isnan(num1) ? '0' : num1; }; 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -