Question

Locked

help on java coding

By warriormage76 ·
this is a form i am trying to get to work in java script (what am i doing wrong cause it does nothing


<html>
<head>
<script language="javascript">

function triangle()
{
/* Calculate the area of a triangle. */
var length, height

length = parseFloat(document.calc.length.value)
if(isNaN(length))
{
alert("You need a value for length.")
document.calc.length.focus()
}
else
{
height = parseFloat(document.calc.height.value)
if(isNaN(height))
{
alert("You need a value for height.")
document.calc.height.focus()
}
else
{
document.calc.area.value = (height * length) / 2
}
}
}
function circle()
{
/* Calculate the area of a Circle. */
var radius

radius = parseFloat(document.calc.radius.value)
if(isNaN(radius))
{
alert("You need a value for radius.")
document.calc.radius.focus()
}
else
{
document.calc.area.value = (raduis * radius) * 3.14

}
}
}
function formReset()
{
document.getElementById("AreaCalculator").reset();
}


</script>

<title> Area Calculator</title>

</head>
<body>
<form name="AreaCalculator">

<table border="1">
<tr>
<td>
Simple Area Calculator:
</td>
</tr>
<tr>
<td>
Triangle Calculation:
</td>
<td>
Circle Calculation:
</td>
</tr>
<tr>
<td>
Length: <input type="text" name="length">
</td>
<td>
Radius: <input type="text" name="radius">
</td>
</tr>
<tr>
<td>
Height: <input type="text" name="height">
</td>
<td>
Area: <input type="text" name="triangle()">
</td>
</tr>
<tr>
<td>
Area: <input type="text" name="circle()">
</td>
<td>
<input type="button" value="Calculate Area" onclick="triangle()">
</td>
</tr>
<tr>
<td>
<input type="button" value="Calculate Area" onclick="circle()">
</td>
<td>
<input type="button" onclick="formReset()" value="Reset">
</td>
</tr>
</table>

</body>
</html>

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Back to Software Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums