Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   Изменение в js (https://javascript.ru/forum/misc/71919-izmenenie-v-js.html)

KATRIN1786492 21.12.2017 17:40

Изменение в js
 
подскажите, я ввожу число, оно умножается на 25, как в коде, но когда убираю это число , значение все равно остается, как сделать так, чтобы значение становилось 0?


<h6>
By the new year we have prepared a special offer for you. For each purchase in our store you will receive bonus points, which you can exchange for any sneakers.1 purchase = 25 bonuses.To exchange bonuses for sneakers, you need to collect 150 bonuses.
</h6></p>
<br>
<br>
<h7> How many pairs of sneakers did you buy? <br>
 <h5><input type="number" onkeyup="bonus(this.value)"></h5>
 <br>
<div id="otpt">Bonuses</div>
 <script>
 function bonus(value){
 	if(value > 0){
          document.getElementById("otpt").innerHTML = (value*25) + "  Bonuses";
        }
    }

void() 22.12.2017 03:33

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<h6>
By the new year we have prepared a special offer for you. For each purchase in our store you will receive bonus points, which you can exchange for any sneakers.1 purchase = 25 bonuses.To exchange bonuses for sneakers, you need to collect 150 bonuses.
</h6></p>
<br>
<br>
<h7> How many pairs of sneakers did you buy? <br>
 <h5><input type="number" onkeyup="bonus(this.value)"></h5>
 <br>
<div id="otpt">Bonuses</div>
 <script>
 function bonus(value){
 	if(value > 0){
          document.getElementById("otpt").innerHTML = (value*25) + "  Bonuses";
        }else{
        	document.getElementById("otpt").innerHTML = 0 + "  Bonuses";
        }
    }
</script>
</body>
</html>


Часовой пояс GMT +3, время: 23:44.