Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
October 21st, 2002, 06:38 PM
 TracyD
Junior Member

Join Date: Oct 2002
Location: Atlanta GA
Posts: 15
Time spent in forums: < 1 sec
Reputation Power: 0

I need help with this Java Script problem. It is supposed to be able to solve the problem

c*c=a*a=B*b or c squared= a squared*bsquared

and I need the answer to pop up in a new page in a new javascript and have a close tag. (window.close)

I'm so lost...my second wk of javascript in school and I have NO idea what I'm doing. Could anyone please look at my code and help me?

Thanks,
Tracy

Here it is......

<script language="JavaScript">
<!--hide from old browsers
document.write("This is JavaScript")

function hypotenuse(){

function newWindow(open) {
equation = window.open("open", "equation", "width=330,height=250");
equation.focus();
}

//-->
</script>
<body>
<input type="text" name="a+a" value=""> enter side A.<br>
<input type="text" name="b+b" value=""> enter side B.<br>
<a href="javascript:newWindow(open)"></a>

<input type="button" value="submit"
onClick=" hypotenuse();">

</form>
</body></html>

#2
October 21st, 2002, 08:35 PM
 degsy
Contributing User

Join Date: Nov 2001
Posts: 1,882
Time spent in forums: 5 Days 21 h 19 m 30 sec
Reputation Power: 19
Here is some very basic code to get you going.

Code:
```<html><head><title>Hypotenuse</title>

<script language="JavaScript">
<!--hide from old browsers

function hypotenuse(){
var c = Math.sqrt((a*a)+(b*b))

equation = window.open("open", "equation", "width=330,height=250");
equation.focus();
equation.document.open();
equation.document.write('Hypotenuse = ' + c +'<br><a href="javascript:window.close()">Close this Window</a>');
equation.document.close();
}

//-->
</script>
<body>
<input type="text" name="a" value=""> enter side A.<br>
<input type="text" name="b" value=""> enter side B.<br>

<input type="button" value="submit"
onClick="hypotenuse();">

</form>
</body></html>
```

First, name="a+a" is an invalid name, same with b+b
a*a didn't even exist anyway (remember a+a)

You were missing a closing bracket from the hypotenuse() function.

There are much better ways to use mathematical function in javascript, but I'm also learning and have used the basics to get the result into a new window.

 Viewing: Dev Shed Forums > Web Design > JavaScript Development > Please Help!! Javascript problem: c squared=a squared*b squared