Web Analytics Made Easy -
StatCounter JavaScript Request: unit conversion - CodingForum

Announcement

Collapse
No announcement yet.

JavaScript Request: unit conversion

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • JavaScript Request: unit conversion

    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:
    PHP Code:
    <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.

    Also if it's possible to do so more values can be added as and when that would be good
    Last edited by mouse; Jul 6, 2002, 07:05 PM.
    [+] Computer/PC issues [+] Silverpaw3D
    ------------------------------------------------
    Never buy a dwarf with learning disabilities...

    ...it's not big, and it's not clever.

  • #2
    mou...
    one thing /me just a noticed®??? you donttt have just a ny® <form> n' </form> tags...:O(((
    The New JustaBuster Version 2.0 OR JustaBusta Lite V2.0
    ...just a special® thanx kinda hugs to jkd n' nex ...:O)))

    CommemorateWTC.com --Please lend your support

    Comment


    • #3
      I do, just outside the table, the script works but has a couple of bugs such as not converting from Oz/in.
      [+] Computer/PC issues [+] Silverpaw3D
      ------------------------------------------------
      Never buy a dwarf with learning disabilities...

      ...it's not big, and it's not clever.

      Comment

      Working...
      X