0
The task consists of the following, measuring whether the IQA is good or bad. IQA is a measure of the Air Quality Index. This measurement is done in conjunction with the measurement of two gases: O3, PM10. This way has a table to monitor whether the index is good or bad.
O3 PM10
Índice Maximo Maximo
Muito Bom 59.4 19.4
Bom 119.4 34.4
Medio 179.4 49.4
Fraco 239.4 119.4
Ruim >239.5 >119.5
NOTE: The IQA will be determined by the worst index. When the O3 is "bad" the IQA will be "bad". Similarly when the PM10 is bad the IQA will be "bad". The worst index will determine the IQA
Here is my code. However my doubt is that this code works but it always writes that it is "VERY GOOD" and I am not able to fix it.
<head>
<title>CalculoDeIQA</title>
<meta charset="UTF-8"/>
</head>
<body>
<h1>Forneça o indice de PM10 e 03 para o cálculo do IQA </h1>
PM10:<input type="text" name="PM10" id="PM10id">
<br>
O3: <input type="text" name="O3" id="O3id" >
<br>
<br>
Enviar: <input type="submit" name="enviar" onclick="calculaIqa()">
<script language="JavaScript">
var O3=document.getElementById("O3id");
var PM10=document.getElementById("PM10id");
function calculaIqa(){
if((O3>=239.5) || (PM10>=119.5)){
document.write("IQA ruim ");
}
if((O3>=239.4) || (PM10>=119.4)){
documento.write("IQA fraco");
}
if(O3>=179.4||PM10>=49.4){
document.write("IQA medio");
}
if((O3>=119.4)||(PM10>=34.4)){
document.write("medio");
}
if((O3>=59.4) || (PM10>=19.4)){
document.write("IQA bom");
}else{
document.write("IQA Muito Bom");
}
}
</script>
</body>
</html>
Could you explain to me what this line is in the code ? Document.getElementById("Bt"). addeventlistener("click", Function(){ calculaIqa(); });
– Gabriel Silva
yes, it is to associate the event "onclick" on the button with id "Bt", for example
<button id="bt" onclick="calculalqa()">
. Is that I tested the code first on the site http://jsfiddle.net/ and there this second way does not work– Ricardo Pontual