Script Categories













Calculators >>> Straight Distance.

Enter a coordinate pair for each the starting and ending points according to the Cartesian coodinate system. The script will calculate the straight line distance between the two points.

Distance Calculator: From point A to point B
Point A Point B
(xA, yA) (xB, yB)

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function distance(form) {
var x1 = eval(form.x1.value);
var y1 = eval(form.y1.value);
var x2 = eval(form.x2.value);
var y2 = eval(form.y2.value);
var xdiff = x2 - x1;
var ydiff = y2 - y1;
form.answer.value = Math.pow((xdiff * xdiff + ydiff * ydiff), 0.5);
}
//  End -->
</script>
<form>
<table border=3 cellspacing=2 cellpadding=5>
<tr>
<td
colspan=4 align=center>Distance Calculator: From point A to point B</td>
</tr>
<tr>
<td
colspan=2 align=center>Point A</td>
<td
colspan=2 align=center>Point B</td>
</tr>
<tr>
<td
align=center>(x<sub>A</sub>,</td>
<td
align=center>y<sub>A</sub>)</td>
<td
align=center>(x<sub>B</sub>,</td>
<td
align=center>y<sub>B</sub>)</td>
</tr>
<tr>
<td
align=center><input type=text name=x1 size=5></td>
<td
align=center><input type=text name=y1 size=5></td>
<td
align=center><input type=text name=x2 size=5></td>
<td
align=center><input type=text name=y2 size=5></td>
</tr>
<tr>
<td
colspan=4 align=center><input type=button value="Solve Distance" onClick="distance(this.form)"></td>
</tr>
<tr>
<td
colspan=4 align=center><input type=text name=answer size=20></td>
</tr>
</table>
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).

Bitcoin Gambling - The Original Crypto Dice Game . Site
©

©©




©