Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
2
Indexable
Never
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8">
<title>
the area of a triangle
</title>
</head>
<body style="text-align: center;">
<label for="side1">
Enter the value of side 1:
</label>
<input type="number" id="side1"
placeholder="Enter value of side 1">
<br><br>
<label for="side2">
Enter the value of side 2:
</label>
<input type="number" id="side2"
placeholder="Enter value of side 2">
<br><br>

<label for="side3">
Enter the value of side 3:
</label>
<input type="number" id="side3"
placeholder="Enter value of side 3">
<br><br>
<button onclick="Area()">Click Here!</button>
<p>
Area of Triangle: <span id="display"></span>
</p>
<script type="text/javascript">
function Area() {
var side1 = parseInt(document
.getElementById("side1").value);
var side2 = parseInt(document
.getElementById("side2").value);
var side3 = parseInt(document
.getElementById("side3").value);
console.log(typeof(side1));
var s = (side1 + side2 + side3) / 2;
var area = Math.sqrt(s * ((s - side1)
* (s - side2) * (s - side3)));
document.getElementById(
"display").innerHTML = area;}
</script>
</body>
</html>