Envato Earnings Calculator
HTML
Insert Sales Volume:
<input type="text" id="value_e" />
<a href="#" onclick="calculate_e();">Calculate</a><br />
Earnings: <span id="result_e"></span>
JavaScript
function calculate_e() {
var value = document.getElementById('value_e').value;
var total = 0;
var income = 0;
var breakpoint = 3750;
var percentage = 70;
while (total < value) {
if (total == breakpoint) {
if(percentage<70) {
percentage = percentage + 1;
}
breakpoint = breakpoint + 3750;
}
total = total+1;
income = income + 1*(percentage/100);
}
document.getElementById('result_e').innerHTML = '$'+income.toFixed(2)+'<br />Percentage:'+percentage;
}