-1
People would like the "status" field to change its value, if the value of the "quantity" field was less than 5.
I tried the code below but it doesn’t work. I don’t know where I’m going wrong
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var x = document.getElementById("quantidade")
function aviso(){
if(x < 5){
document.getElementById("status").value = 'Quantidade crítica. Comprar mais!!'
}else{
document.getElementById("status").value = 'Em estoque'
}
}
</script>
<title>teste</title>
</head>
<body>
Quantidade: <input type="text" id="quantidade" onkeyup="aviso()"><br><br>
status: <input type="text" id="status"><br><br>
</body>
</html>
thanks @chriptus13, it only works when I compare x to a number. when I compare it to a y variable, it only works in iteration. knows how to solve this?
– Allan Cisneiro
Don’t forget to mark as correct.
– chriptus13