Below is the HTML code for doing some calculations (this has been whittled down to the bear necessities).
The form requires two inputs, then “Calculates” the remaining four values.
Everything runs fine using the expression f.M.value = eval (f.OD.value * 3); but this is not the correct expression that is needed, it’s just a test expression.
If the correct expression, f.M.value = eval (f.OD.value + (3 * W) - (1.5155 / NT) ); is used instead, it returns nothing and shows an “Error on page.” down on the status bar.
The problem seems to lie in the addition (+) portion of the expression.
For testing purposes use:
OD = .625
NT = 11
CALCULATE - This will return:
P = 0.091
PD = 0.56595
W = 0.05254
and M = 1.875
If the f.M.value expression is changed to the correct one, it should return 0.6448.
(alerts are just in there for testing).
What am I missing?
Any ideas on fixing this?
Thanks for any help you all can give.
Oak
The form requires two inputs, then “Calculates” the remaining four values.
Everything runs fine using the expression f.M.value = eval (f.OD.value * 3); but this is not the correct expression that is needed, it’s just a test expression.
If the correct expression, f.M.value = eval (f.OD.value + (3 * W) - (1.5155 / NT) ); is used instead, it returns nothing and shows an “Error on page.” down on the status bar.
The problem seems to lie in the addition (+) portion of the expression.
For testing purposes use:
OD = .625
NT = 11
CALCULATE - This will return:
P = 0.091
PD = 0.56595
W = 0.05254
and M = 1.875
If the f.M.value expression is changed to the correct one, it should return 0.6448.
(alerts are just in there for testing).
Code:
<HTML>
<HEAD>
<TITLE>3 WIRE CALCULATIONS</TITLE>
</HEAD>
<SCRIPT language=javascript>
<!--- Hide script from old browsers
function compute(f)
{
f.P.value=(eval (1 / f.NT.value).toFixed(3) );
//alert ("P = " + f.P.value );
f.PD.value = (eval (f.OD.value -(.6495 / f.NT.value)).toFixed(5) );
//alert ("PD = " + f.PD.value );
f.W.value = (eval (.57735 * f.P.value).toFixed(5) );
//alert ("W = " + f.W.value );
//This is the correct expression
//f.M.value = eval (f.OD.value + (3 * W) - (1.5155 / NT) );
//This expression is for testing
f.M.value = (eval (f.OD.value * 3));
alert ("M = " + f.M.value );
}
// end hiding from old browsers -->
</SCRIPT>
<BODY>
<CENTER>
<FORM>
<TABLE cellSpacing=0 cellPadding=1 border=2 width=45% bgcolor=#cccccc>
<TR>
<TD colspan=4 bgColor=#330099 align=center><B><FONT face="Arial" color=#ffffff size=2>3 WIRE</FONT></B></TD>
</TR>
<TR>
<TD ALIGN=CENTER colspan=4><B><FONT face="Arial" size=2>Thread Input Dimensions:</FONT></B></TD>
</TR>
<TR>
<TD align=center><FONT face="Arial" size=2>Threads Size:</FONT></TD>
<TD align=center><FONT size=1>5/8 = .625</font><BR>
<FONT face="Arial" size=1 color=red>(OD)</FONT></TD>
<TD align=center><FONT size=2>
<INPUT name=OD size=10> </FONT></TD>
</TR>
<TR>
<TD align=center><FONT face="Arial" size=2>No. of Threads per inch (TPI):</FONT></TD>
<TD align=center><FONT size=1 color=red>(NT)</FONT></TD>
<TD align=center><FONT size=2>
<INPUT name=NT size=10> </FONT></TD>
</TR>
<TR>
<TD colspan=3 align=center>
<INPUT onclick=compute(this.form) type=button value=Calculate name=Calculate>
<INPUT type=reset value=" Clear " name=name>
</TD>
</TR>
<TR>
<TD colSpan=3 align=center><B><FONT face="Arial" size=2>Resulting Thread Information:</FONT></B></TD>
</TR>
<TR>
<TD align=center><FONT face="Arial" size=2>Pitch:</FONT></TD>
<TD align=center><FONT size=1 color=#ff0000>(P)</FONT></TD>
<TD align=center><FONT size=3>
<INPUT name=P size=10> </FONT></TD>
</TR>
<TR>
<TD align=center><FONT face="Arial" size=2>Pitch Diameter:</FONT></TD>
<TD align=center><FONT color=#ff0000 size=1>(PD)</FONT></TD>
<TD align=center><FONT size=2>
<INPUT name=PD size=10> </FONT></TD>
</TR>
<TR>
<TD align=center><FONT face="Arial" size=2>Best Wire:</FONT></TD>
<TD align=center><FONT size=1 color=#ff0000>(W)</FONT></TD>
<TD align=center><FONT size=3>
<INPUT name=W size=10> </FONT></TD>
</TR>
<TR>
<TD align=center><FONT face="Arial" size=2>3 Wire Distance:</FONT></TD>
<TD align=center><FONT size=1 color=#ff0000>(M)</FONT></TD>
<TD align=center><FONT size=2>
<INPUT name=M size=10> </FONT></TD>
</TR>
</TABLE>
</FORM>
</CENTER>
</BODY>
</HTML>
What am I missing?
Any ideas on fixing this?
Thanks for any help you all can give.
Oak