var count = 0;
function StartAdd() {
while (count < 5) {
document.getElementById("Inputs").innerHTML += "
";
count++;
}
}
function Add() {
var ToString = "";
if (count < 10) {
for (var i = 0; i < count; i++) {
ToString += "
";
}
document.getElementById("Inputs").innerHTML = ToString + "
";
count++;
Math(); // Math after add new line
} else {
alert("אפשר להוסיף עד 10 תיבות"); // If you to try add new line (after 10 - max) show error message
}
}
function Round(num) { if (num - parseInt(num) != 0) return (parseInt(num) + 1); return num ; }
function Math() { var sum = 0; var max = 0;
for (var i = 0; i < count; i++) { if (max < document.getElementById("input" + i).value) max = document.getElementById("input" + i).value; } for (var i = 0; i < count; i++) { sum = (100 - sum) * document.getElementById("input" + i).value / 100 + sum; } document.getElementById("Math").innerHTML = Round(sum) + "%"; } function Clear() { document.getElementById("Math").innerHTML = 'לחץ על חשב אחוזים'; document.getElementById("form").reset(); } //StartAdd();