javascript - How can i change the negative numbers to 0 from my webpage -
i'm trying convert or disable negative numbers 0 on
website appear when select products on column 'unidad minima' , 'unidad maxima'for example 10 or more each one.
i've tried using format number jquery plugin didn't work in case.
there code webpage.
$("tr.txtmult").each(function () { var $val3 = $('.val3', this).val(); cantidadesminimas = (8260 - cantidadfinal) / $val3; cantidadesmaximas = (12390 - cantidadfinal) / $val3; $('.val5', this).html(cantidadesminimas.tofixed(0)); $('.val6', this).html(cantidadesmaximas.tofixed(0)); }); $("#cantidadmin").html(8260 - cantidadfinal.tofixed(0)); $("#cantidadmax").html(12390 - cantidadfinal.tofixed(0));
}
some comment apreciated.
thanks!
you use short if else this:
$('.val5', this).html((cantidadesminimas < 0 ? 0 : cantidadesminimas));
Comments
Post a Comment