Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| proportion_converter [2025/02/27 04:51] – Scott Larson | proportion_converter [2025/06/07 02:18] (current) – Scott Larson | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Proportion Converter ====== | ====== Proportion Converter ====== | ||
| - | <button type=" | + | [[https://eyefixer.org/proportion-converter/|Start Converter]] |
| - | + | ||
| - | < | + | |
| - | < | + | |
| - | <meta charset=" | + | |
| - | <meta name=" | + | |
| - | < | + | |
| - | </ | + | |
| - | < | + | |
| - | < | + | |
| - | body { | + | |
| - | font-family: | + | |
| - | margin: 20px; | + | |
| - | padding: 20px; | + | |
| - | max-width: 1000px; | + | |
| - | } | + | |
| - | h3 { | + | |
| - | color: #4307f6; | + | |
| - | } | + | |
| - | label { | + | |
| - | font-weight: | + | |
| - | } | + | |
| - | input, button { | + | |
| - | margin-top: 5px; | + | |
| - | padding: 8px; | + | |
| - | font-size: 16px; | + | |
| - | } | + | |
| - | p { | + | |
| - | font-size: 18px; | + | |
| - | font-weight: | + | |
| - | color: blue; | + | |
| - | margin-top: 10px; | + | |
| - | } | + | |
| - | </style> | + | |
| - | <!-- Equation for A = 100 / B --> | + | |
| - | < | + | |
| - | <label for=" | + | |
| - | <input type=" | + | |
| - | <button onclick=" | + | |
| - | < | + | |
| - | <p id=" | + | |
| - | < | + | |
| - | <!-- Equation for C = (1/D)* 100 --> | + | |
| - | < | + | |
| - | <label for=" | + | |
| - | <input type=" | + | |
| - | <button onclick=" | + | |
| - | < | + | |
| - | <p id=" | + | |
| - | + | ||
| - | < | + | |
| - | function calculateA() { | + | |
| - | let B = parseFloat(document.getElementById(" | + | |
| - | let resultElement = document.getElementById(" | + | |
| - | + | ||
| - | if (B === 0) { | + | |
| - | resultElement.innerHTML = "Value cannot be zero"; | + | |
| - | return; | + | |
| - | } | + | |
| - | if (isNaN(B)) { | + | |
| - | resultElement.innerHTML = " | + | |
| - | return; | + | |
| - | } | + | |
| - | let A = 100 / B; | + | |
| - | let formattedA = A.toLocaleString(); | + | |
| - | + | ||
| - | resultElement.innerHTML = "The occurrence is <b>1 in " + formattedA + "</ | + | |
| - | } | + | |
| - | + | ||
| - | function calculateC() { | + | |
| - | let D = parseFloat(document.getElementById(" | + | |
| - | let resultElement = document.getElementById(" | + | |
| - | + | ||
| - | if (D === 0) { | + | |
| - | resultElement.innerHTML = "Value cannot be zero"; | + | |
| - | return; | + | |
| - | } | + | |
| - | if (isNaN(D)) { | + | |
| - | resultElement.innerHTML = " | + | |
| - | return; | + | |
| - | } | + | |
| - | let C = (1 / D) * 100; | + | |
| - | resultElement.innerHTML = "This equals <b> " + C + " % </ | + | |
| - | } | + | |
| - | + | ||
| - | // Listen for " | + | |
| - | document.getElementById(" | + | |
| - | if (event.key === " | + | |
| - | calculateA(); | + | |
| - | } | + | |
| - | }); | + | |
| - | + | ||
| - | // Listen for " | + | |
| - | document.getElementById(" | + | |
| - | if (event.key === " | + | |
| - | calculateC(); | + | |
| - | } | + | |
| - | }); | + | |
| - | </ | + | |
| - | </ | + | |
| - | </ | + | |
| {{tag> | {{tag> | ||