function calculateFeedRate() {
var spindleSpeed = parseFloat(document.getElementById("spindleSpeed").value);
var feedPerRevolution = parseFloat(document.getElementById("feedPerRevolution").value);
var numberOfTeeth = parseFloat(document.getElementById("numberOfTeeth").value); // Included for context, not used in main formula here
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(spindleSpeed) || isNaN(feedPerRevolution)) {
resultDiv.innerHTML = "Please enter valid numbers for Spindle Speed and Feed Per Revolution.";
return;
}
if (spindleSpeed <= 0 || feedPerRevolution <= 0) {
resultDiv.innerHTML = "Spindle Speed and Feed Per Revolution must be positive values.";
return;
}
var feedRate = spindleSpeed * feedPerRevolution;
resultDiv.innerHTML = "
Result:
" +
"
Feed Rate: " + feedRate.toFixed(3) + " mm/min (or inch/min)";
}
.calculator-widget {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 600px;
margin: 20px auto;
background-color: #f9f9f9;
}
.calculator-title {
text-align: center;
color: #333;
margin-bottom: 20px;
}
.calculator-inputs {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 15px;
margin-bottom: 20px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
.input-group input {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1em;
}
.calculator-actions {
text-align: center;
margin-bottom: 20px;
}
.calculator-actions button {
padding: 10px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1.1em;
transition: background-color 0.3s ease;
}
.calculator-actions button:hover {
background-color: #0056b3;
}
.calculator-results {
background-color: #e9ecef;
padding: 15px;
border-radius: 4px;
text-align: center;
border: 1px solid #ced4da;
}
.calculator-results p {
margin: 0;
font-size: 1.1em;
color: #333;
}
.calculator-results strong {
color: #007bff;
}
.calculator-explanation {
margin-top: 25px;
padding-top: 15px;
border-top: 1px solid #eee;
font-size: 0.95em;
line-height: 1.6;
color: #444;
}
.calculator-explanation h3, .calculator-explanation h4 {
color: #333;
margin-bottom: 10px;
}
.calculator-explanation ul {
margin-left: 20px;
margin-bottom: 10px;
}
.calculator-explanation li {
margin-bottom: 5px;
}
.error {
color: #dc3545;
font-weight: bold;
}