Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

Organizational Research By

Surprising Reserch Topic

Javascript adding integers


How do I add a simple integer to another integer in Javascript?

I'm getting NaN as the value for total.

 type="text/javascript">
var total = 0;
document.getElementById("dds1").onkeyup = function() {
    total = total + parseInt(this.value,10);
    updateIt();

};

function updateIt() {
//tofixed(2)
    document.getElementById("mySpan").innerHTML = total;
}

But if I do the following:

total = parseInt(this.value,10);

asked May 19, 2015 in JAVASCRIPT by rajesh
0 votes
9 views



Related Hot Questions



Government Jobs Opening


...