javascript bigger than if statement not working correctly -


i no expert in javascript, hope can me out.

i have following code, reason thinks statement true

delvnum=document.getelementbyid("deliverynum").value; delvqty=document.getelementbyid("delvqty"+id).value; orderqty=document.getelementbyid("orderqty"+id).value;  if (delvqty>orderqty) {   alert("can't deliver more " + orderqty + ", trying deliver " + delvqty + ". please fix!");   document.getelementbyid("delvqty"+id).focus();   return; } 

the error message show quantity of each var, , correctly being passed through.

you comparing strings , not numbers.

use parseint or parsefloat

if (parsefloat(delvqty)>parsefloat(orderqty)) 

or

if (parseint(delvqty,10)>parseint(orderqty,10)) 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -