<!DOCTYPE html>
<html>
<head>
<title>Home Lab 4</title>
<head>
</head>
<body>
<table border="4px" bordercolor="navy" bgcolor="white" cellpadding="4px">
<tr>
<td>X-coordinate 1:</td>
<td><input type="text" id="x1"></td>
<td>X-coordinate 2:</td>
<td><input type="text" id="x1"></td>
</tr>
<tr>
<td>Y-coordinate 1:</td>
<td><input type="text" id="x1"></td>
<td>Y-coordinate 2:</td>
<td><input type="text" id="x1"></td>
</center>
</table>
<script type="text/javascript">
function distance()
{
distance=sqrt( (x2 - x1)^2 + (y2 - y2)^2 )
var a = [564,426];
var b = [56,784];
var xN = Math.pow( b[0] - a[0], 2 );
var yN = Math.pow( b[1] - a[1], 2 );
var distance = Math.sqrt(xN + yN);
alert(distance);
}
</script>
<br>
<input type="button" onclick="distance()" value="distance">
</body>
</html>
我不确定问题是什么,但我无法得到要计算的值。我还需要弹出警报以显示计算值的帮助。我试过无数次改变不同的东西,一切都保持不变。任何帮助都会非常好。提前致谢!