Javascript number comparison fails

Because you’re comparing strings, not integers. Use parseInt to explicitly cast your values as integers.

Here’s essentially what you’re doing: jsFiddle example

To do the conversion, change your variables to something like:

var new_da1 = parseInt( document.getElementById('new_da1').value, 10);

(assuming they’re all integers)

Leave a Comment