...

View Full Version : JavaScript Request: unit conversion



mouse
07-06-2002, 11:52 PM
Hi
I'd like a script to convert any 1 of 4 values into its equivalents. I've managed to do this by converting and hacking up a temperature script from JSK but there's a bug as I'm involving 4 different units and the script I manipulated dealt with 3 and frankly my JS knowledge is *limited*

Here's what I had:

<table>
<tr><td width="175"><p align="right">Newton meters (Nm):</p></td>
<td>
<INPUT TYPE="text" NAME="Nm" VALUE="" SIZE="9" MAXLENGTH="9" onChange="eval('lbin.value = ' + this.form.lbin_expr.value);eval('lbft.value = ' + this.form.lbft_expr.value);eval('ozin.value = ' + this.form.ozin_expr.value)">
<INPUT TYPE="hidden" NAME="Nm_expr" VALUE="(ozin.value / 141.69)">
</td></tr>
<tr><td>
<p align="right">Pound feet (Lb/ft):</p></td>
<td>
<INPUT TYPE="text" NAME="lbft" VALUE="" SIZE="9" MAXLENGTH="9" onChange="eval('Nm.value = ' + this.form.Nm_expr.value);eval('lbin.value = ' + this.form.lbin_expr.value);eval('ozin.value = ' + this.form.ozin_expr.value)">
<INPUT TYPE="hidden" NAME="lbft_expr" VALUE="((Nm.value * 8.85)/12)">
</td></tr>
<tr><td>
<p align="right">Pound inches (Lb/in):</p></td>
<td>
<INPUT TYPE="text" NAME="lbin" VALUE="" SIZE="9" MAXLENGTH="9" onChange="eval('Nm.value = ' + this.form.Nm_expr.value);eval('lbft.value = ' + this.form.lbft_expr.value);eval('ozin.value = ' + this.form.ozin_expr.value)">
<INPUT TYPE="hidden" NAME="lbin_expr" VALUE="(Nm.value * 8.85)">
</td></tr>
<tr><td>
<p align="right">Ounce inches (oz/in):</p></td>
<td>
<INPUT TYPE="text" NAME="ozin" VALUE="" SIZE="9" MAXLENGTH="9" onChange="eval('Nm.value = ' + this.form.Nm_expr.value);eval('lbft.value = ' + this.form.lbft_expr.value);eval('lbin.value = ' + this.form.lbin_expr.value)">
<INPUT TYPE="hidden" NAME="ozin_expr" VALUE="((lbft.value * 12)* 16)">
</td></tr>
<tr>
<td colspan="2">
<hr>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<INPUT TYPE="button" NAME="Reset" VALUE="Submit">
<INPUT TYPE="Reset" NAME="Reset" VALUE="Reset">
</td></tr>
</table>Any assistance I'd be grateful for. :eek::)

Also if it's possible to do so more values can be added as and when that would be good ;)

justame
07-07-2002, 03:44 AM
mou...
one thing /me just a noticed®??? you donttt have just a ny® <form> n' </form> tags...:O(((

mouse
07-07-2002, 07:21 PM
I do, just outside the table, the script works but has a couple of bugs such as not converting from Oz/in.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum