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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -