Forums

Javascript calculator

Invidia81 05 Aug, 2019
Hello,

I made a calcutor for reefaquarium additions. http://dsr.dekock.pro/
Everything works just fine, except the last. The dropdown D1-D15 does not change Carbon field.
Only if i change the Volume afterwards it works.

What can be the problem here ?
Thx in advance.

This is the js code:
function calcular() {

var volume = parseFloat(document.getElementById('volume').value);
var days = parseFloat(document.getElementById('days').value);

var buffer = parseFloat(document.getElementById('buffer').value);
var khsetpoint = parseFloat(document.getElementById('kh_setpoint').value);
var kh_difference = khsetpoint - buffer;
document.getElementById('kh_difference').value = kh_difference.toFixed(1);

var calcium = parseFloat(document.getElementById('calcium').value);
var calciumsetpoint = parseFloat(document.getElementById('calcium_setpoint').value);
var calcium_difference = calciumsetpoint - calcium;
document.getElementById('calcium_difference').value = calcium_difference.toFixed(1);

var buffer_corr_total = (volume / 100) * kh_difference * 16.7;
document.getElementById('ez_buffer_total').value = buffer_corr_total.toFixed(1);
var buffer_corr_daily = ((volume / 100) * kh_difference * 16.7) / days;
document.getElementById('ez_buffer_daily').value = buffer_corr_daily.toFixed(1);

var calcium_corr_total = (volume / 100) * calcium_difference * 0.578;
document.getElementById('ez_calcium_total').value = calcium_corr_total.toFixed(1);
var calcium_corr_daily = ((volume / 100) * calcium_difference * 0.578) / days;
document.getElementById('ez_calcium_daily').value = calcium_corr_daily.toFixed(1);

var trace_total = calcium_corr_total / 2;
var trace_daily= calcium_corr_daily / 2
document.getElementById('ez_trace_total').value = trace_total.toFixed(1);
document.getElementById('ez_trace_daily').value = trace_daily.toFixed(1);

var max_carbon = (volume / 100) * 12.38;
document.getElementById('maximum').value = max_carbon.toFixed(2);

var day_carbon = parseFloat(document.getElementById('days_of_dosing').value);
var carbon_doses = (volume / 100) * day_carbon
document.getElementById('carbon').value = carbon_doses.toFixed(2);
This topic is locked and no more replies can be posted.