I would like to have several conversion scripts run on a single html page...
Right now, one will work, but the others will not. Want to have them
all available and function.
Thanks in advance!
Example of 2 of the scripts:
<p>
<table>
<script>
<!-- // --> <h1>Your browser does not support <a
href="http://www.netscape.com/comprod/products/navigator/version_2.0/script/script_info/">JavaScript</a>,
sorry</h1>.
<!-- // -->The conversion table below will not work with your browser<p><hr>
<!--
function Area() {
this.mm2=0.000001
this.cm2=0.0001
this.decm=0.01
this.dekm=100
this.xxx2=0.09290304/144
this.ft2=0.09290304
this.centiare=1
this.meter2=1
this.yd2=0.09290304*9
this.are2=100
this.acre=0.09290304*43560
this.cacre=0.09290304*36000
this.hectare=10000
this.km2=1000000
this.mi2=0.09290304*27878400
}
data = new Area();
function checkNum(str) {
for (var i=0; i<str.length; i++) {
var ch = str.substring(i, i + 1)
if (ch!="." && ch!="+" && ch!="-" && ch!="e" && ch!="E" && (ch < "0"
|| ch > "9")) {
alert("Please enter a valid number.");
return false
}
}
return true
}
function normalize(what,digits) {
var str=""+what;
var pp=Math.max(str.lastIndexOf("+"),str.lastIndexOf("-"));
var idot=str.indexOf(".");
if (idot>=1) {
var ee=(pp>0)?str.substring(pp-1,str.length):"";
digits+=idot;
if (digits>=str.length)
return str;
if (pp>0 && digits>=pp)
digits-=pp;
var c=eval(str.charAt(digits));
var ipos=digits-1;
if (c>=5) {
while (str.charAt(ipos)=="9") ipos--;
if (str.charAt(ipos)==".") {
var nc=eval(str.substring(0,idot))+1;
if (nc==10 && ee.length>0) {
nc=1;
ee="e"+(eval(ee.substring(1,ee.length))+1);
}
return ""+nc+ee;
}
return str.substring(0,ipos)+(eval(str.charAt(ipos))+1)+ee;
} else
var ret=str.substring(0,digits)+ee;
for (var i=0; i<ret.length; i++)
if (ret.charAt(i)>"0" && ret.charAt(i)<="9")
return ret;
return str;
}
return str;
}
function compute(obj,val) {
if (obj[val].value) {
var uval=0;
uval = obj[val].value*data[val];
for (var i in data)
obj[i].value=normalize(uval/data[i],8);
}
}
// -->
</SCRIPT>
<left>
<p>
<TR>
<TD ALIGN="left">
<TABLE ID="mens suits" BORDER=0 CELLSPACING=3 CELLPADDING=1 WIDTH=525>
<TR>
<TD COLSPAN=8 BGCOLOR="#003060" HEIGHT=15>
<P ALIGN=LEFT><FONT SIZE="3"
FACE="Arial,Helvetica,Sans-serif,sans-serif"></FONT><FONT
COLOR="#efefef" SIZE="3"
FACE="Arial,Helvetica,Sans-serif,sans-serif"><B>Area</B></FONT><B></B></P>
</TD>
</TR>
</p>
</left>
</br>
</br>
<P><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=3 WIDTH="100%">
<CENTER>
<table border="0">
<colgroup>
<col width="270">
<col width="20">
<col width="270">
</colgroup>
<center>
<tr><td align="right"><b>Quadratmillimeter</b></br> mm²</right></td>
<td><center><input type="text" name="mm2" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>square millimeter</b></br> mm², sq
mm</left></td>
</tr>
</center>
<tr><td align="right"><b>Quadratzentimeter</b></br>cm²</right></td>
<td><center><input type="text" name="cm2" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>square centimeter</b></br> cm², sq
cm</left></td>
</tr>
</center>
<tr><td align="right"><b>Quadratdezimeter</b></br>dm²</right></td>
<td><center><input type="text" name="decm" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>square decimeter</b></br> dm², sq dm</left></td>
</tr>
</center>
<tr><td align="right"><b>Quadratmeter</b></br>m²</right></td>
<td><center><input type="text" name="meter2" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>square meter</b></br> m², sq m</left></td>
</tr>
<tr><td align="right"><b>Quadratdekameter</b></br> </right></td>
<td><center><input type="text" name="dekm" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>square
dek(c)ameter</b></br> dam², sq dam</left></td>
</tr>
</center>
<tr><td align="right"><b>Quadratkilometer</b></br>km²</right></td>
<td><center><input type="text" name="km2" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>square kilometer</b></br> km², sq km</left></td>
</tr>
<tr><td align="right"><b>Hektar</b></br> </right></td>
<td><center><input type="text" name="hectare" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>hectare</b></br> ha</left></td>
</tr>
<tr><td align="right"><b>Ar</b></br> </right></td>
<td><center><input type="text" name="are" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>are</b></br> a</left></td>
</tr>
<tr><td align="right"><b></b></br> </right></td>
<td><center><input type="text" name="centiare" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>centiare</b></br> ca</left></td>
</tr>
<p>
<td align="center"
<tr>
<td align="center"><input name="clear1" type="reset" value="Clear"> </td>
</tr>
</center>
</p>
<tr><td align="right"><b>Quadratzoll</b></br> </right></td>
<td><center><input type="text" name="xxx2" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>square inch</b></br> in², sq in</left></td>
</tr>
</center>
<tr><td align="right"><b>Quadratfuss</b></br> </right></td>
<td><center><input type="text" name="ft2" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)" </td>
<td align="left"><b>square foot</b></br> ft², sq ft</left></td>
</tr>
</center>
<tr><td align="right"><b>Quadratyard</b></br> </right></td>
<td><center><input type="text" name="yd2" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>square yard</b></br> yd², sq yd</left></td>
</tr>
<tr><td align="right"><b>Quadratmeile</b></br> mi²</right></td>
<td><center><input type="text" name="mi2" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>square mile</b></br> mi², sq mi</left></td>
</tr>
<tr><td align="right"><b>Acker</b></br> </right></td>
<td><center><input type="text" name="acre" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>acre</b></br> ac</left></td>
</tr>
<tr><td align="right"><b></b></br> </right></td>
<td><center><input type="text" name="cacre" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</td>
<td align="left"><b>acre (commercial)</b></br> ac</left></td>
</tr>
</center>
</table>
</p>
<p>
<table>
<script>
<!-- // --> <h1>Your browser does not support <a
href="http://www.netscape.com/comprod/products/navigator/version_2.0/script/script_info/">JavaScript</a>,
sorry</h1>.
<!-- // -->The conversion table below will not work with your browser<p><hr>
<!--
function DISTANCE() {
this.mm=0.001
this.cm=0.01
this.dcm=0.10
this.dam=10
this.inch=0.3048/12
this.ft=0.3048
this.meter=1
this.yd=0.9144
this.km=1000
this.mi=0.3048*5280
this.nmi=1852
}
data = new DISTANCE();
function checkNum(str) {
for (var i=0; i<str.length; i++) {
var ch = str.substring(i, i + 1)
if (ch!="." && ch!="+" && ch!="-" && ch!="e" && ch!="E" && (ch < "0"
|| ch > "9")) {
alert("Please enter a valid number.");
return false
}
}
return true
}
function normalize(what,digits) {
var str=""+what;
var pp=Math.max(str.lastIndexOf("+"),str.lastIndexOf("-"));
var idot=str.indexOf(".");
if (idot>=1) {
var ee=(pp>0)?str.substring(pp-1,str.length):"";
digits+=idot;
if (digits>=str.length)
return str;
if (pp>0 && digits>=pp)
digits-=pp;
var c=eval(str.charAt(digits));
var ipos=digits-1;
if (c>=5) {
while (str.charAt(ipos)=="9") ipos--;
if (str.charAt(ipos)==".") {
var nc=eval(str.substring(0,idot))+1;
if (nc==10 && ee.length>0) {
nc=1;
ee="e"+(eval(ee.substring(1,ee.length))+1);
}
return ""+nc+ee;
}
return str.substring(0,ipos)+(eval(str.charAt(ipos))+1)+ee;
} else
var ret=str.substring(0,digits)+ee;
for (var i=0; i<ret.length; i++)
if (ret.charAt(i)>"0" && ret.charAt(i)<="9")
return ret;
return str;
}
return str;
}
function compute(obj,val) {
if (obj[val].value) {
var uval=0;
uval = obj[val].value*data[val];
for (var i in data)
obj[i].value=normalize(uval/data[i],8);
}
}
// -->
</SCRIPT>
<left>
<p>
<TR>
<TD ALIGN="left">
<TABLE ID="mens suits" BORDER=0 CELLSPACING=3 CELLPADDING=1 WIDTH=525>
<TR>
<TD COLSPAN=8 BGCOLOR="#003060" HEIGHT=15>
<P ALIGN=LEFT><FONT SIZE="3"
FACE="Arial,Helvetica,Sans-serif,sans-serif"></FONT><FONT
COLOR="#efefef" SIZE="3"
FACE="Arial,Helvetica,Sans-serif,sans-serif"><B>Distance</B></FONT><B></B></P>
</TD>
</TR>
</p>
</left>
</br>
</br>
<P><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=3 WIDTH="100%">
<CENTER>
<table border="0">
<colgroup>
<col width="270">
<col width="20">
<col width="270">
</colgroup>
<center>
<tr><td align="right"><b>Millimeter</b></br>mm</right></td>
<td><center><input type="text" name="mm" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</br> </td>
<td align="left"><b>millimeter</b></br>mm</left></td>
</tr>
</center>
<tr><td align="right"><b>Zentimeter</b></br>cm</right></td>
<td><center><input type="text" name="cm" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</br> </td>
<td align="left"><b>centimter</b></br>cm</left></td>
</tr>
</center>
<tr><td align="right"><b>Dezimeter</b></br>dm</right></td>
<td><center><input type="text" name="dcm" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</br> </td>
<td align="left"><b>decimeter</b></br>dm</left></td>
</tr>
</center>
<tr><td align="right"><b>Meter</b></br>m</right></td>
<td><center><input type="text" name="meter" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</br> </td>
<td align="left"><b>meter</b></br>m</left></td>
</tr>
</center>
<tr><td align="right"><b>Dekameter</b></br>dam</right></td>
<td><center><input type="text" name="dam" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</br> </td>
<td align="left"><b>dek(c)ameter</b></br>dam</left></td>
</tr>
</center>
<tr><td align="right"><b>Kilometer</b></br>km</right></td>
<td><center><input type="text" name="km" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</br></td>
<td align="left"><b>kilometer</b></br>km</left></td>
</tr>
</center>
<p>
<td align="center"
<tr>
<td align="center"><input name="clear1" type="reset" value="Clear"> </td>
</tr>
</center>
</p>
<tr><td align="right"><b>Zoll</b></br>('')</right></td>
<td><center><input type="text" name="inch" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)" </td>
<td align="left"><b>inch</b></br>in,('')</left></td>
</tr>
</center>
<tr><td align="right"><b>Fuss</b></br>(')</right></td>
<td><center><input type="text" name="ft" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</br></td>
<td align="left"><b>foot</b></br>ft,(')</left></td>
</tr>
</center>
<tr><td align="right"><b>Yard</b></br> </right></td>
<td><center><input type="text" name="yd" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</br> </td>
<td align="left"><b>yard</b></br>yd</left></td>
</tr>
</center>
<tr><td align="right"><b>Meile</b></br> </right></td>
<td><center><input type="text" name="mi" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</br></td>
<td align="left"><b>mile</b></br>mi</left></td>
</tr>
<tr><td align="right"><b>Seemeile</b></br>sm</right></td>
<td><center><input type="text" name="nmi" size="11" onchange="if
(checkNum(this.value))compute(this.form,this.name)"</br></td>
<td align="left"><b>mile (nautical)</b></br>nm</left></td>
</tr>
</center>
</table>
</p> |