Results
Enter the values above to see the calculated photosynthesis rate.
function calculatePhotosynthesisRate() {
var volumeCO2 = parseFloat(document.getElementById("volumeCO2").value);
var timePeriod = parseFloat(document.getElementById("timePeriod").value);
var leafArea = parseFloat(document.getElementById("leafArea").value);
var resultDiv = document.getElementById("result");
if (isNaN(volumeCO2) || isNaN(timePeriod) || isNaN(leafArea)) {
resultDiv.innerHTML = "Please enter valid numbers for all fields.";
return;
}
if (timePeriod <= 0 || leafArea <= 0) {
resultDiv.innerHTML = "Time period and leaf area must be greater than zero.";
return;
}
// Calculate the rate of photosynthesis in mL CO2 / cm² / minute
var rate = volumeCO2 / (timePeriod * leafArea);
resultDiv.innerHTML = "Rate of Photosynthesis:
" + rate.toFixed(4) + " mL CO₂ / cm² / min";
}
.calculator-wrapper {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 600px;
margin: 20px auto;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.calculator-input-section, .calculator-output-section {
margin-bottom: 20px;
}
.calculator-input-section h2, .calculator-output-section h2 {
margin-top: 0;
color: #333;
}
.input-group {
margin-bottom: 15px;
}
.input-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
.input-group input[type="number"] {
width: calc(100% – 22px);
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1rem;
}
button {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #45a049;
}
#result {
background-color: #f9f9f9;
padding: 15px;
border: 1px solid #eee;
border-radius: 4px;
min-height: 50px;
display: flex;
align-items: center;
}
#result p {
margin: 0;
font-size: 1.1rem;
color: #333;
}
#result strong {
color: #007bff;
}