Lite Em Up Son
New member
I need to put a calculator I have in javascript, in a Html table...i have this code so far...
<html>
<title> this is a test !! </title>
<head>
newer test..putting java in body
</head>
<body>
<table border>
<tr>
<script="javascript">
function distance(x1,y1,x2,y2){
var dx=x1-x2;
var dy=y1-y2;
return Math.sqrt(dx*dx+dy*dy);
}
function compute(b){
var f=b.form;
f.result.value=distance(f.x1.value, f.y1.value, f.x2.value, f.y2.value);
}
<input type="text" name="x1" value="">
<input type="text" name="y1" value="">
<input type="text" name="x2" value="">
<input type="text" name="y2" value="">
<input type="button" value="Compute" onClick="compute(this)">
<input type="text" name="result" value="0">
</script>
</tr>
</table>
</body>
</html>
someone help please?? The javascript portion shows up as text...and it doesn't compute..i really need help asap!! thank you!
that just made it worse...i dont know what to do
<html>
<title> this is a test !! </title>
<head>
newer test..putting java in body
</head>
<body>
<table border>
<tr>
<script="javascript">
function distance(x1,y1,x2,y2){
var dx=x1-x2;
var dy=y1-y2;
return Math.sqrt(dx*dx+dy*dy);
}
function compute(b){
var f=b.form;
f.result.value=distance(f.x1.value, f.y1.value, f.x2.value, f.y2.value);
}
<input type="text" name="x1" value="">
<input type="text" name="y1" value="">
<input type="text" name="x2" value="">
<input type="text" name="y2" value="">
<input type="button" value="Compute" onClick="compute(this)">
<input type="text" name="result" value="0">
</script>
</tr>
</table>
</body>
</html>
someone help please?? The javascript portion shows up as text...and it doesn't compute..i really need help asap!! thank you!
that just made it worse...i dont know what to do