Ejemplos en Javascript

Metrology Equivalents

Conversor

<HTML>
<HEAD>

<TITLE>Ejemplos Javascript: ejemplo pr???¡ctico </TITLE>

<!-- Cut-N-Paste JavaScript from ISN Toolbox
Copyright 1996, Infohiway Server Network.  Restricted use is hereby
granted (both personal and commercial use OK so long as this code is
not *directly* sold), providing this notice is buried somewhere deep
in your HTML document.  A link to http://www.infohiway.com is always
appreciated, but is absolutely and positively not necessary. :-) -->

<SCRIPT LANGUAGE="JavaScript">
<!-- Hide JavaScript from Java-Impaired Browsers
function initArray() {
  this.length = initArray.arguments.length;
  for (var i = 0; i < this.length; i++) {
    this[i] = initArray.arguments[i];
    }
  }
/* Please don't ask about this work-around. It works... We're sure arrays
    will be better supported soon. */
var isn02 = new initArray("4b","5b","8b","8b");
isn02[0] = "~01~10.003937~20.0001~30.0003404~40.00003937~50.000003937~60.0000001~70.000000003937~8";
isn02[1] = "~0254~11~20.0254~30.086~40.01~50.001~60.0000254~70.000001~8";
isn02[2] = "~010~139.37~21~33.404~40.3937~50.03937~60.001~70.00003937~8";
isn02[3] = "~02937.5~111.566~20.29375~31~40.11566~50.011566~60.00029375~70.000011566~8";
isn02[4] = "~025400~1100~22.54~38.646~41~50.1~60.00254~70.0001~8";
isn02[5] = "~0254000~11000~225.4~386.46~410~51~60.0254~70.001~8";
isn02[6] = "~010000000~139370~21000~33404~4393.7~539.37~61~70.03937~8";
isn02[7] = "~0254000000~11000000~225400~386460~410000~51000~625.4~71~8";


function metCon() {
  // First, get the variables checked by the user
  for (var i = 0; i < 8; i++) {
    if (document.isnform02.meti[i].checked) {
      meti = i;
      metinm = document.isnform02.meti[i].value;
      }
    }
  for (var i = 0; i < 8; i++) {
    if (document.isnform02.meto[i].checked) {
      meto = i;
      metonm = document.isnform02.meto[i].value;
      }
    }
  // Now grab the number input by user and parse to be sure numeric
  useri = document.isnform02.metinp.value;
  if (useri == 0) {
    useri = 1;
    document.isnform02.metinp.value = useri;
    }
  mulstr = isn02[meti];
  picker = "~" + meto;
  ps = mulstr.indexOf(picker);
  meto++;
  picker = "~" + meto;
  ps1 = mulstr.indexOf(picker);
  mulstr = mulstr.substring((ps + 2),ps1);
  ps = (useri * mulstr);
  picker = "";
  picker += ps
  ps1 = picker.indexOf(".");
  if (ps1 > -1) {
    // Correct for binary/floating point conversion error
    ps = ps + .000001;
    picker = "";
    picker += ps;
    ps2 = picker.indexOf("e");
    if (ps2 < 0) {
      picker = picker.substring(0,(ps1 + 6));
      }
    if (ps2 == 0 || ps2 > 0) {
      ps3 = picker.indexOf("00000");
      if (ps3 > 0) {
        picker = picker.substring(0,ps3 + 1) + picker.substring(ps2,picker.length);
        }
      }
    }
  picker = useri + " " + metinm + " = " + picker + " " + metonm
  document.isnform02.metout.value = picker;
  }
// End Hiding -->
</SCRIPT>


</HEAD>

<BODY bgcolor="white">

<TABLE BORDER=1 WIDTH=486>
<TR><TD COLSPAN=9 ALIGN=CENTER><FORM NAME="isnform02"><FONT COLOR="blue"><B>Metrology Equivalents</B></FONT></TD></TR>
<TR><TD COLSPAN=9 VALIGN=TOP><FONT SIZE=1><B>First, type the number you wish converted here: </B>
<INPUT TYPE="text" NAME="metinp" SIZE=30 VALUE="" onChange="metCon();"><BR><B>Then, click radio buttons for desired conversion:</FONT></TD></TR>
<TR><TD ALIGN=CENTER><FONT COLOR="red" SIZE=1><B>From:</B></FONT></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Angstrom Units<BR><INPUT TYPE="radio" NAME="meti" VALUE="Angstrom Units" CHECKED onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Surface Microinch<BR><INPUT TYPE="radio" NAME="meti" VALUE="Surface Microinch" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Surface Microns<BR><INPUT TYPE="radio" NAME="meti" VALUE="Surface Microns" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Light Bands*<BR><INPUT TYPE="radio" NAME="meti" VALUE="Light Bands" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Precision tenths<BR><INPUT TYPE="radio" NAME="meti" VALUE="Precision tenths" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Close Tol. thousandths<BR><INPUT TYPE="radio" NAME="meti" VALUE="Close Tol. thousandths" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Metric Milimeters<BR><INPUT TYPE="radio" NAME="meti" VALUE="Metric Milimeters" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>U.S. Inches<BR><INPUT TYPE="radio" NAME="meti" VALUE="U.S. Inches" onClick = ""></TD></TR>
<TR><TD ALIGN=CENTER><FONT COLOR="red" SIZE=1><B>To:</B></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Angstrom Units<BR><INPUT TYPE="radio" NAME="meto" VALUE="Angstrom Units" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Surface Microinches<BR><INPUT TYPE="radio" NAME="meto" VALUE="Surface Microinches" CHECKED onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Surface Microns<BR><INPUT TYPE="radio" NAME="meto" VALUE="Surface Microns" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Light Bands*<BR><INPUT TYPE="radio" NAME="meto" VALUE="Light Bands" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Precision tenths<BR><INPUT TYPE="radio" NAME="meto" VALUE="Precision tenths" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Close Tol. thousandths<BR><INPUT TYPE="radio" NAME="meto" VALUE="Close Tol. thousandths" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Metric Milimeters<BR><INPUT TYPE="radio" NAME="meto" VALUE="Metric Milimeters" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>U.S. Inches<BR><INPUT TYPE="radio" NAME="meto" VALUE="U.S. Inches" onClick = ""></TD></TR>
<TR><TD COLSPAN=9 ALIGN=CENTER VALIGN=TOP><FONT SIZE=1><INPUT TYPE="button" VALUE=" Click for Conversion " onClick="metCon();"> <INPUT TYPE="reset" VALUE=" Reset Values "><BR><INPUT TYPE="text" NAME="metout" SIZE=60 VALUE="" onClick="lenCon();"><BR>* Monochromatic helium count
</FONT></TD></TR>
</TABLE></FORM>


</body>
</html>

Conversores