mirror of
https://github.com/hexahigh/games.git
synced 2025-12-11 20:15:38 +01:00
21 lines
739 B
HTML
21 lines
739 B
HTML
<script>
|
|
function percentage(partialValue, totalValue) {
|
|
return (100 * partialValue) / totalValue;
|
|
}
|
|
|
|
function docalc(){
|
|
const num2 = document.getElementById("input2").value;
|
|
const num1 = document.getElementById("input1").value;
|
|
var calcu = percentage(num1, num2);
|
|
|
|
//percentage(num1, num2)
|
|
document.getElementById("output").value = calcu
|
|
}
|
|
</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> |