I'm kind of stuck cause whenever I click the Calculate Distance button after entering numbers for x1,x2,y1,y2 everything clears instead of calculating
function calculateDistance()
{
var pointx1 = parseInt(document.getElementById("pointx1").value);
var pointy1 = parseInt(document.getElementById("pointy1").value);
var pointx2 = parseInt(document.getElementById("pointx2").value);
var pointy2 = parseInt(document.getElementByID("pointy2").value);
var distance = Math.sqrt(Math.Pow((pointx1-pointx2),2)+Math.Pow((pointy1-pointy2),2));
window.alert("Distance: "+distance);
}
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title> Distant Points </title>
<script type = "text/javascript"> </script>
</head>
<body>
<form name = "f1" method="post">
<label>Point 1:</label><br>
x:<input type = "text" id = "pointx1" size = "30"/> y1:<input type = "text" id = "pointy1" size = "30"/> <br>
<label>Point 2:</label> <br>
x:<input type = "text" id = "pointx2" size = "30"/> y2:<input type = "text" id = "pointy2" size = "30"/>
<button onclick = "calculateDistance()">Calculate Distance</button>
</form>
</body>
</html>