Skip to content

Instantly share code, notes, and snippets.

@pejantantangguh
Created September 16, 2019 06:39
Show Gist options
  • Save pejantantangguh/cb63dbf0befa2d45136ec053c124d748 to your computer and use it in GitHub Desktop.
Save pejantantangguh/cb63dbf0befa2d45136ec053c124d748 to your computer and use it in GitHub Desktop.
Calculator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div>
<form name="wallPaperCalc">
<input type="number" name="width" id="width" placeholder="Input Width in cm" value="">
<input type="number" name="length" id="length" placeholder="Input Length in cm" value="">
<p>Results : <span id="qtyNeeded"></span></p>
<button type="submit" value="Submit" id="submit" onclick="calc()">Submit</button>
</form>
</div>
<script>
// document.getElementById("qtyNeeded").innerHTML = calc(qtyNeeded);
function calc() {
let width, length, result;
let wallPaperSize = 38
length = Number(document.wallPaperCalc.length.value);
width = Number(document.wallPaperCalc.width.value);
result = Math.ceil(((length * width) / 10000) / wallPaperSize);
alert(result);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment