added some error handling
This commit is contained in:
@@ -3,7 +3,7 @@ buttoncalc.addEventListener("click", calculate)
|
|||||||
|
|
||||||
function calculate(){
|
function calculate(){
|
||||||
let aromaamount = document.getElementById("aromaamount").value
|
let aromaamount = document.getElementById("aromaamount").value
|
||||||
let aromaconc = document.getElementById("aromaconc").value
|
let aromaconc = document.getElementById("aromaconc").value / 100
|
||||||
let vg = document.getElementById("vg").value
|
let vg = document.getElementById("vg").value
|
||||||
let pg = document.getElementById("pg").value
|
let pg = document.getElementById("pg").value
|
||||||
let other = document.getElementById("other").value
|
let other = document.getElementById("other").value
|
||||||
@@ -13,6 +13,10 @@ function calculate(){
|
|||||||
let nicshotvg = document.getElementById("nicshotvg").value
|
let nicshotvg = document.getElementById("nicshotvg").value
|
||||||
let nicshotpg = document.getElementById("nicshotpg").value
|
let nicshotpg = document.getElementById("nicshotpg").value
|
||||||
|
|
||||||
|
if(vg * 1 + pg * 1 + other * 1 != 100){
|
||||||
|
} else if(nicshotvg * 1 + nicshotpg * 1 != 100){
|
||||||
|
} else {
|
||||||
|
|
||||||
document.getElementById("results").style.display="block"
|
document.getElementById("results").style.display="block"
|
||||||
let volume = aromaamount / aromaconc
|
let volume = aromaamount / aromaconc
|
||||||
let countnicshot = (volume * nicdose) / (nicshotamount * nicshotnicppm)
|
let countnicshot = (volume * nicdose) / (nicshotamount * nicshotnicppm)
|
||||||
@@ -25,5 +29,5 @@ function calculate(){
|
|||||||
document.getElementById("amountothers").value = amountothers
|
document.getElementById("amountothers").value = amountothers
|
||||||
document.getElementById("amountvg").value = amountvg
|
document.getElementById("amountvg").value = amountvg
|
||||||
document.getElementById("amountpg").value = amountpg
|
document.getElementById("amountpg").value = amountpg
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
<td><input type="text" id="aromaamount" name="aromaamount"></td>
|
<td><input type="text" id="aromaamount" name="aromaamount"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="aromaconc"> Aromakonzentration:</label></td>
|
<td><label for="aromaconc"> Aromakonzentration in %:</label></td>
|
||||||
<td><input type="text" id="aromaconc" name="aromaconc"></td>
|
<td><input type="text" id="aromaconc" name="aromaconc"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
Reference in New Issue
Block a user