# Calculates The Distance Between Two Points (x1, y1) And (x2, y2). All Numbers And Return Values Should Be Floating-Point Values

Write function distance that calculates the distance between two points (x1, y1) and (x2, y2). All numbers and return values should be floating-point values. Incorporate this function into a script that enables the user to enter the coordinates of the points through an HTML form.Bottom of Form

Copy Code From Here

distence.html

<html>
<script>
function find_distance()
{
var x1=parseInt(document.getElementById("x1").value);
var y1=parseInt(document.getElementById("y1").value);
var x2=parseInt(document.getElementById("x2").value);
var y2=parseInt(document.getElementById("y2").value);
var distance=Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1-y2),2));
}
</script>
<body>
<form name="f1" method="post">
<label>Enter the co-ordinate of point p:</label><br>
x1:<input type="text" id="x1" size="30"/>&nbsp;y1:<input type="text" id="y1" size="30"/><br>
<label>Enter the co-ordinate of point q:</label><br>
x2:<input type="text" id="x2" size="30"/>&nbsp;y2:<input type="text" id="y2" size="30"/><br>
<button onclick="find_distance()">Find Distance</button>
</form>
</body>
</html

Output:-