thanx again, after ur fair comment about my 'weird' syntax i decided to go back to the book, anyway i managed to get it working but it returns in radians, cant get conversion formula to work /radians*(180/PI) /

Code:

<html>
<body>
<script type="text/javascript">
function writeText (form) {
var E1=form.inputbox1.value;
var N1=form.inputbox2.value;
var E2=form.inputbox3.value;
var N2=form.inputbox4.value;
var E;
var N;
E=(E2-E1)*(E2-E1);
N=(N2-N1)*(N2-N1);
form.inputbox5.value = Math.sqrt(E+N);
var e;
var n;
e=E2-E1;
n=N2-N1;
var B;
var b;
b=e/n;
if (n<0) { B = Math.atan(b)+180; }
else if (n>0) { B = Math.atan(b); }
else if (e>0) { B=90; }
else {B=270; }
if (B<0){B=B+360; }
return B;
// form.inputbox6.value = B;
}
var A
A=B*(180/PI)
form.inputbox6.value = A;
</script>
<form name="myform">Eastings 1:<input type="text" name="inputbox1" value="">
<br>Northings 1:<input type="text" name="inputbox2" value="">
<br>
<br>Eastings 2:<input type="text" name="inputbox3" value="">
<br>Northings 2:<input type="text" name="inputbox4" value="">
<br>
<br>Distance:<input type="text" name="inputbox5" value="">
<br>
<br>Bearing:<input type="text" name="inputbox6" value="">
<br>
<input type="button" name="button" value="Calculate" onclick="writeText(this.form)">
</form>
</body>
</html>