Result
Please enter the values above to calculate the infusion rate.
function calculateInfusionRate() {
var volumeToInfuse = parseFloat(document.getElementById("volumeToInfuse").value);
var infusionTime = parseFloat(document.getElementById("infusionTime").value);
var resultDiv = document.getElementById("result");
if (isNaN(volumeToInfuse) || isNaN(infusionTime) || volumeToInfuse <= 0 || infusionTime <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for volume and time.";
return;
}
var infusionRate = volumeToInfuse / infusionTime; // mL per minute
resultDiv.innerHTML = "Infusion Rate:
" + infusionRate.toFixed(2) + " mL/min";
}
.calculator-container {
font-family: sans-serif;
max-width: 600px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.calculator-form h2, .calculator-result h3 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.calculator-form p {
text-align: center;
color: #555;
margin-bottom: 20px;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #444;
}
.form-group input[type="number"] {
width: calc(100% – 12px);
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box; /* Ensures padding and border are included in the element's total width and height */
}
button {
display: block;
width: 100%;
padding: 10px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
.calculator-result {
margin-top: 20px;
padding: 15px;
background-color: #e9ecef;
border-radius: 4px;
}
.calculator-result p {
margin: 0;
text-align: left;
color: #333;
}
.calculator-result strong {
color: #007bff;
}