Ejemplos en Javascript

Volume/Capacity 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 isn05 = new initArray("4b","5b","8b","8b");
isn05[0] = "~01~10.0005787~20.00002143~30.5541~40.01732~50.01488~60.004329~70.000465~80.01639~9";
isn05[1] = "~01728~11~20.03704~3957.5~429.92~525.71~67.481~70.8036~828.32~9";
isn05[2] = "~046656~127~21~325853~4807.9~5694.3~6202.2~721.70~8764.6~9";
isn05[3] = "~01.805~10.001044~20.00003868~31~40.03125~50.02686~60.007812~70.0008392~80.02957~9";
isn05[4] = "~057.75~10.03342~20.001238~332~41~50.8594~60.25~70.02686~80.9464~9";
isn05[5] = "~067.20~10.03889~20.001440~337.24~41.164~51~60.2909~70.03125~81.101~9";
isn05[6] = "~0231~10.1337~20.004951~3128~44~53.437~61~70.1074~83.785~9";
isn05[7] = "~02150~11.244~20.04609~31192~437.24~532~69.309~71~835.24~9";
isn05[8] = "~061.02~10.03531~20.001308~333.81~41.057~50.9081~60.2642~70.02838~81~9";


function volCon() {
  // First, get the variables checked by the user
  for (var i = 0; i < 9; i++) {
    if (document.isnform05.voli[i].checked) {
      voli = i;
      volinm = document.isnform05.voli[i].value;
      }
    }
  for (var i = 0; i < 9; i++) {
    if (document.isnform05.volo[i].checked) {
      volo = i;
      volonm = document.isnform05.volo[i].value;
      }
    }
  // Now grab the numeric input by user and parse to be sure numeric
  useri = document.isnform05.volinp.value;
  if (useri == 0) {
    useri = 1;
    document.isnform05.volinp.value = useri;
    }
  mulstr = isn05[voli];
  picker = "~" + volo;
  ps = mulstr.indexOf(picker);
  volo++;
  picker = "~" + volo;
  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 + " " + volinm + " = " + picker + " " + volonm
  document.isnform05.volout.value = picker;
  }
// End Hiding -->
</SCRIPT>


</HEAD>

<BODY bgcolor="white">

<TABLE BORDER=1 WIDTH=486>
<TR><TD COLSPAN=10 ALIGN=CENTER><FORM NAME="isnform05"><FONT COLOR="blue"><B>Volume/Capacity Equivalents</B></FONT></TD></TR>
<TR><TD COLSPAN=10 VALIGN=TOP><FONT SIZE=1><B>First, type the number you wish converted here: </B>
<INPUT TYPE="text" NAME="volinp" SIZE=30 VALUE="" onChange="volCon();"><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>Cubic Inches<BR><INPUT TYPE="radio" NAME="voli" VALUE="Cubic Inches" CHECKED onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Cubic Feet<BR><INPUT TYPE="radio" NAME="voli" VALUE="Cubic Feet" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Cubic Yards<BR><INPUT TYPE="radio" NAME="voli" VALUE="Cubic Yards" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>US Fluid Ounces*<BR><INPUT TYPE="radio" NAME="voli" VALUE="Fluid Ounces" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>US Liquid Quarts<BR><INPUT TYPE="radio" NAME="voli" VALUE="US Liquid Quarts" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>US Dry Quarts<BR><INPUT TYPE="radio" NAME="voli" VALUE="US Dry Quarts" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>US Gallons<BR><INPUT TYPE="radio" NAME="voli" VALUE="US Gallons" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>US Bushels<BR><INPUT TYPE="radio" NAME="voli" VALUE="US Bushels" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Liters<BR> <BR><INPUT TYPE="radio" NAME="voli" VALUE="Liters" onClick = ""></TD></TR>
<TR><TD ALIGN=CENTER><FONT COLOR="red" SIZE=1><B>To:</B></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Cubic Inches<BR><INPUT TYPE="radio" NAME="volo" VALUE="Cubic Inches" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Cubic Feet<BR><INPUT TYPE="radio" NAME="volo" VALUE="Cubic Feet" CHECKED onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Cubic Yards<BR><INPUT TYPE="radio" NAME="volo" VALUE="Cubic Yards" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>US Fluid Ounces*<BR><INPUT TYPE="radio" NAME="volo" VALUE="Fluid Ounces" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>US Liquid Quarts<BR><INPUT TYPE="radio" NAME="volo" VALUE="US Liquid Quarts" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>US Dry Quarts<BR><INPUT TYPE="radio" NAME="volo" VALUE="US Dry Quarts" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>US Gallons<BR><INPUT TYPE="radio" NAME="volo" VALUE="US Gallons" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>US Bushels<BR><INPUT TYPE="radio" NAME="volo" VALUE="US Bushels" onClick = ""></TD>
<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=1>Liters<BR> <BR><INPUT TYPE="radio" NAME="volo" VALUE="Liters" onClick = ""></TD></TR>
<TR><TD COLSPAN=10 ALIGN=CENTER VALIGN=TOP><FONT SIZE=1><INPUT TYPE="button" VALUE=" Click for Conversion " onClick="volCon();"> <INPUT TYPE="reset" VALUE=" Reset Values "><BR><INPUT TYPE="text" NAME="volout" SIZE=60 VALUE="" onClick="volCon();"><BR>* Apothecary
</FONT></TD></TR>
</TABLE></FORM>


</body>
</html>

Conversores