Php javascript框不显示-值
我希望在用户单击-按钮时不显示我的负号。计数应在0结束。 它现在也显示-1、-2、-3个字符。我只想显示0或多个0Php javascript框不显示-值,php,javascript,html,Php,Javascript,Html,我希望在用户单击-按钮时不显示我的负号。计数应在0结束。 它现在也显示-1、-2、-3个字符。我只想显示0或多个0 <script type="text/javascript" > function plus(){ var addplus = 1; var plus = document.getElementById('qty').v
<script type="text/javascript" >
function plus(){
var addplus = 1;
var plus = document.getElementById('qty').value;
addplus = parseInt(addplus) + parseInt(plus);
document.getElementById('qty').value = addplus;
}
function negtive(){
var neg;
var negtive = 1;
var negtives = document.getElementById('qty').value;
negtive = parseInt(negtives) - parseInt(negtive);
document.getElementById('qty').value = negtive;
}
</script>
函数plus(){
var addplus=1;
var plus=document.getElementById('qty').value;
addplus=parseInt(addplus)+parseInt(plus);
document.getElementById('qty')。value=addplus;
}
函数负(){
var neg;
var负值=1;
var negatives=document.getElementById('qty').value;
negative=parseInt(negatives)-parseInt(negative);
document.getElementById('qty')。值=负数;
}
把这行
if(negtive<0)
negtive = 0;
或
document.getElementById('qty').value=((负数)我只希望我的负值现在应该显示在框中,请再次检查..您拼写错误了负数..请在回答中更正..复制并粘贴..负数的拼写是“负数”,而不是“负数”
negtive = parseInt(negtives) - parseInt(negtive);
document.getElementById('qty').value = ((negtive <0)?0:negtive );