mirror of
https://github.com/hexahigh/games.git
synced 2025-12-11 20:15:38 +01:00
added percentage calculator
This commit is contained in:
parent
d048ca00b6
commit
cf21f4f15c
20
tools/percentage-calc/index.html
Normal file
20
tools/percentage-calc/index.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<script>
|
||||||
|
function percentage(partialValue, totalValue) {
|
||||||
|
return (100 * partialValue) / totalValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function docalc(){
|
||||||
|
const num2 = document.getElementById("input2");
|
||||||
|
const num1 = document.getElementById("input1");
|
||||||
|
|
||||||
|
percentage(num1, num2)
|
||||||
|
document.getElementById("output").value = percentage(num1, num2)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<h1>Percentage calculator</h1><br>
|
||||||
|
<p>Calculate <textarea id="input1"></textarea> Out of <textarea id="input2"></textarea></p>
|
||||||
|
<label>Output</label><br>
|
||||||
|
<textarea id="output" rows="6" cols="80" readonly></textarea><br>
|
||||||
|
<button type="button" id="copy" onclick="docalc();">Calculate</button>
|
||||||
|
</body>
|
||||||
Loading…
x
Reference in New Issue
Block a user