I’m trying to get this assignment done for a Javascript class that I’ve been working on for almost 2 weeks now. Basically the script has to take inputs on 3 sides of a triangle and tell you if they are valid or not using the 3/4/5 rule. If it turns out to be a right triangle it has to pop up an alert box to tell you that as well. The script keeps taking inputs until you quit. Here’s what I have so far, I’d appreciate it if someone could steer me in the right direction:
[code]
<html>
<head>
<title> Programming Assignment 2 </title>
<body>
<h1> Programming Assignment 2 – Triangle Calculator </h1>
<h3>Please input the lengths of the 3 sides of the triangle in the boxes below.</h3>
<form name=”Triangle”>
Side 1: <input type=”text” name=”sidea” value=””><br/>
Side 2: <input type=”text” name=”sideb” value=””><br/>
Side 3: <input type=”text” name=”sidec” value=””><br/>
<input type=”reset” name=”reset1″ value=”Clear”>
<input type=”submit” name=”submit1″ value=”Submit”>
</form>
<script type=”text/javascript”>
document.forms[“Triangle”]
val1 = parseInt(sidea);
val2 = parseInt(sideb);
val3 = parseInt(sidec);
function right(){
if ((Math.pow(val1,1/2)) + (Math.pow(val2,1/2)) == Math.pow(val3,1/2))
if ((Math.pow(val2,1/2)) + (Math.pow(val3,1/2)) == Math.pow(val1,1/2))
if ((Math.pow(val1,1/2)) + (Math.pow(val3,1/2)) == Math.pow(val2,1/2)){
alert(“This is a right triangle.”);
}
}
function validate(){
if (val1 + val2 > val3 || val1 + val3 > val2 || val2 + val3 > 1){
alert(“This is a valid triangle.”);
}
else{
alert(“This is not a valid triangle.”)
}
}
</script>
<noscript>
<h2>JavaScript is disabled. To see what this assignment does please enable it in your browser.</h2>
</noscript>
</body>
</html>