Hi, I don't really know how to use Javascript. Can you tell me how to align the three tables?
When I type a question (eg: 10 lb to kg) it gives me multiple answers. Please help!
<html>
<head>
<style type="text/css">
// defines the layout classes for the page
body {
background-color:#DFDFDF;
font-family : arial,verdana,helvetica;
font-size:9pt;
}
.title{
font-family : arial,verdana,helvetica;
font-size:10pt;
font-weight:bold;
}
h3 {
font-family : arial,verdana,helvetica;
font-size:9pt;
}
li {
font-family : arial,verdana,helvetica;
font-size:9pt;
}
td,p {
font-family : arial,verdana,helvetica;
font-size:9pt;
}
hr {
border: 1px groove;
}
.main {
background-color:#EFEFEF;
border: 2px groove;
}
.main3 { width:150;
background-color:#C0CDE2;
border: 2px groove;
}
.button {
background-color:#F7D9AC;
}
</style>
<SCRIPT LANGUAGE=JavaScript>
function convert(req_string){
var req_string = document.myform.req_string.value.toLowerCase()
var con = 0
var inch = -5
var cm = -5
var mile = -5
var km = -5
var pounds = -5
var kg = -5
var found_number = -5
var checking = 0
var positive_num = 0
var pattern = " ";
newsite = '<html><head></head><body bgcolor=#DFDFDF><table align=center cellspacing=1 bgcolor="#5F5F5F"><tr><td bgcolor="#EFEFEF"><p style=padding:5><font style="font-family:arial,verdana,helvetica;font-size:9pt;">';
newsite_end = '</font></td></tr></table></body></html>';
words = req_string.split(pattern);
for (i=0; i < words.length; i++) {
if (isNaN(words)){
}
else{
con = words
checking = 0
positive_num = i}
if ((words)== "inch" || (words)== "inches" || (words)== "ins"){
cm = i}
if ((words)== "centimeter" || (words)== "centimeters" || (words)== "cm"){
inch = i}
if ((words)== "mile" || (words)== "miles"){
mile = i}
if ((words)== "kilometer" || (words)== "kilometers" || (words)== "km"){
km = i}
if ((words)== "pound" || (words)== "pounds" || (words)== "lb" || (words)== "lbs"){
pounds = i}
if ((words)== "kilogram" || (words)== "kilograms" || (words)== "kg"){
kg = i}
}
if((con == 0)){checking = 2}
if((kg == -5) && (pounds != -5)){checking = 1}
if((pounds == -5) && (kg != -5)){checking = 1}
if((km == -5) && (mile != -5)){checking = 1}
if((mile == -5) && (km != -5)){checking = 1}
if((cm == -5) && (inch != -5)){checking = 1}
if((inch == -5) && (cm != -5)){checking = 1}
if((inch == -5) && (cm == -5) && (km == -5) && (mile == -5) && (kg == -5) && (pounds == -5)){checking = 3}
if((inch == -5) && (cm == -5) && (km == -5) && (mile == -5) && (kg == -5) && (pounds == -5) && (con == 0)){checking = 4}
if((inch != -5) && (cm != -5) || (mile != -5) && (km != -5) || (kg != -5) && (pounds != -5)){
if((positive_num)+ 1 == cm){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con/2.56)*1000)/1000 + " Inches")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
else{
if(inch < cm){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con * 2.56)*1000)/1000 + " Centimeters")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
}
if((positive_num) + 1 == inch){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con * 2.56)*1000)/1000 + " Centimeters")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
else{
if(cm < inch){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con/2.56)*1000)/1000 + " Inches")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
}
if((positive_num)+ 1 == km){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con/1.609)*1000)/1000 + " miles")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
else{
if(mile < km){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con * 1.609)*1000)/1000 + " kilometers")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
}
if((positive_num) + 1 == mile){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con * 1.609)*1000)/1000 + " kilometers")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
else{
if(km < mile){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con/1.609)*1000)/1000 + " miles")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
}
if((positive_num) + 1 == kg){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con / 0.45)*1000)/1000 + " Pounds")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
else{
if(pounds < kg){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con / 0.45)*1000)/1000 + " Pounds")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
}
if(positive_num + 1 == pounds){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con / 2.204623)*1000)/1000 + " Kilograms")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
else{
if(kg < pounds){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con / 2.204623)*1000)/1000 + " Kilograms")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
}
}
if((checking == 1)){
document.write(newsite +"You tried to convert two unspeified units please do not")
document.write("<BR>" + "<BR><input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)}
if(checking == 2){
document.write(newsite +"No number was found please leave a space after the number.")
document.write("<BR>" + "<BR><input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)}
if(checking == 3){
document.write(newsite +"Only a number was found please enter measurements.")
document.write("<BR>" + "<BR><input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)}
if(checking == 4){
document.write(newsite +"You did not enter anything in the conversion box.")
document.write("<BR>" + "<BR><input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)}
}
</SCRIPT>
</head>
<table border="0" width="500" align=center class=main>
<tr>
<td>
<BLOCKQUOTE><font class=title>Unit Conversion</font>
<p align=justify> U.C.</p><hr>
<table border="0" width="33%">
<tr><td valign=top>
<table border="9" class=main3>
<tr><th>
Lengths
</th></tr><tr><td><LI>Centimeter</LI>
<LI>Centimeters</LI>
<LI>Cm</LI><BR><BR>
<hr><LI>Inch</LI>
<LI>Inches</LI>
<LI>Ins</LI><hr>
</td></tr></table></td>
<td valign=top>
<table border="9" align=center class=main3><tr><th>
Distances</th></tr><tr><td>
<LI>Kilometer</LI>
<LI>Kilometers</LI>
<LI>Km</LI><br><br><hr>
<LI>Mile</LI>
<LI>Miles</LI><br><br><br><hr>
</td></tr></table></td></tr></table><br><br> <td valign=top>
<table border="9" align=right class=main3>
<tr><th>Weights</th></tr><tr><td>
<LI>Pound</LI>
<LI>Pounds</LI>
<LI>Lb</LI>
<LI>Lbs</LI><br><hr>
<LI>Kilogram</LI>
<LI>Kilograms</LI>
<LI>Kg</LI><br><br><hr> </td></tr></table></td></tr></table><br><br>
<font color="#FF5F00"> Type your request here :</font><BR><BR>
<form name = myform>
<input type = text name = req_string size = 50>
<input type = button value = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/">http://www.webdeveloper.com/forum/archive/index.php/</a><!-- m -->"Convert" onclick = convert() class=button><br>
</form>
</BLOCKQUOTE></td></tr></table>
</body>
</html>
When I type a question (eg: 10 lb to kg) it gives me multiple answers. Please help!
<html>
<head>
<style type="text/css">
// defines the layout classes for the page
body {
background-color:#DFDFDF;
font-family : arial,verdana,helvetica;
font-size:9pt;
}
.title{
font-family : arial,verdana,helvetica;
font-size:10pt;
font-weight:bold;
}
h3 {
font-family : arial,verdana,helvetica;
font-size:9pt;
}
li {
font-family : arial,verdana,helvetica;
font-size:9pt;
}
td,p {
font-family : arial,verdana,helvetica;
font-size:9pt;
}
hr {
border: 1px groove;
}
.main {
background-color:#EFEFEF;
border: 2px groove;
}
.main3 { width:150;
background-color:#C0CDE2;
border: 2px groove;
}
.button {
background-color:#F7D9AC;
}
</style>
<SCRIPT LANGUAGE=JavaScript>
function convert(req_string){
var req_string = document.myform.req_string.value.toLowerCase()
var con = 0
var inch = -5
var cm = -5
var mile = -5
var km = -5
var pounds = -5
var kg = -5
var found_number = -5
var checking = 0
var positive_num = 0
var pattern = " ";
newsite = '<html><head></head><body bgcolor=#DFDFDF><table align=center cellspacing=1 bgcolor="#5F5F5F"><tr><td bgcolor="#EFEFEF"><p style=padding:5><font style="font-family:arial,verdana,helvetica;font-size:9pt;">';
newsite_end = '</font></td></tr></table></body></html>';
words = req_string.split(pattern);
for (i=0; i < words.length; i++) {
if (isNaN(words)){
}
else{
con = words
checking = 0
positive_num = i}
if ((words)== "inch" || (words)== "inches" || (words)== "ins"){
cm = i}
if ((words)== "centimeter" || (words)== "centimeters" || (words)== "cm"){
inch = i}
if ((words)== "mile" || (words)== "miles"){
mile = i}
if ((words)== "kilometer" || (words)== "kilometers" || (words)== "km"){
km = i}
if ((words)== "pound" || (words)== "pounds" || (words)== "lb" || (words)== "lbs"){
pounds = i}
if ((words)== "kilogram" || (words)== "kilograms" || (words)== "kg"){
kg = i}
}
if((con == 0)){checking = 2}
if((kg == -5) && (pounds != -5)){checking = 1}
if((pounds == -5) && (kg != -5)){checking = 1}
if((km == -5) && (mile != -5)){checking = 1}
if((mile == -5) && (km != -5)){checking = 1}
if((cm == -5) && (inch != -5)){checking = 1}
if((inch == -5) && (cm != -5)){checking = 1}
if((inch == -5) && (cm == -5) && (km == -5) && (mile == -5) && (kg == -5) && (pounds == -5)){checking = 3}
if((inch == -5) && (cm == -5) && (km == -5) && (mile == -5) && (kg == -5) && (pounds == -5) && (con == 0)){checking = 4}
if((inch != -5) && (cm != -5) || (mile != -5) && (km != -5) || (kg != -5) && (pounds != -5)){
if((positive_num)+ 1 == cm){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con/2.56)*1000)/1000 + " Inches")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
else{
if(inch < cm){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con * 2.56)*1000)/1000 + " Centimeters")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
}
if((positive_num) + 1 == inch){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con * 2.56)*1000)/1000 + " Centimeters")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
else{
if(cm < inch){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con/2.56)*1000)/1000 + " Inches")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
}
if((positive_num)+ 1 == km){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con/1.609)*1000)/1000 + " miles")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
else{
if(mile < km){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con * 1.609)*1000)/1000 + " kilometers")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
}
if((positive_num) + 1 == mile){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con * 1.609)*1000)/1000 + " kilometers")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
else{
if(km < mile){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con/1.609)*1000)/1000 + " miles")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
}
if((positive_num) + 1 == kg){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con / 0.45)*1000)/1000 + " Pounds")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
else{
if(pounds < kg){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con / 0.45)*1000)/1000 + " Pounds")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
}
if(positive_num + 1 == pounds){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con / 2.204623)*1000)/1000 + " Kilograms")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
else{
if(kg < pounds){
document.write(newsite +"You asked: <b>" + req_string + "</b><BR><BR>")
document.write("The answer is " + Math.round((con / 2.204623)*1000)/1000 + " Kilograms")
document.write("<BR><BR>" + "<input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)
checking = 0}
}
}
if((checking == 1)){
document.write(newsite +"You tried to convert two unspeified units please do not")
document.write("<BR>" + "<BR><input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)}
if(checking == 2){
document.write(newsite +"No number was found please leave a space after the number.")
document.write("<BR>" + "<BR><input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)}
if(checking == 3){
document.write(newsite +"Only a number was found please enter measurements.")
document.write("<BR>" + "<BR><input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)}
if(checking == 4){
document.write(newsite +"You did not enter anything in the conversion box.")
document.write("<BR>" + "<BR><input type=button class=button onclick=history.back() value='http://www.webdeveloper.com/forum/archive/index.php/Next Convert!'>"+newsite_end)}
}
</SCRIPT>
</head>
<table border="0" width="500" align=center class=main>
<tr>
<td>
<BLOCKQUOTE><font class=title>Unit Conversion</font>
<p align=justify> U.C.</p><hr>
<table border="0" width="33%">
<tr><td valign=top>
<table border="9" class=main3>
<tr><th>
Lengths
</th></tr><tr><td><LI>Centimeter</LI>
<LI>Centimeters</LI>
<LI>Cm</LI><BR><BR>
<hr><LI>Inch</LI>
<LI>Inches</LI>
<LI>Ins</LI><hr>
</td></tr></table></td>
<td valign=top>
<table border="9" align=center class=main3><tr><th>
Distances</th></tr><tr><td>
<LI>Kilometer</LI>
<LI>Kilometers</LI>
<LI>Km</LI><br><br><hr>
<LI>Mile</LI>
<LI>Miles</LI><br><br><br><hr>
</td></tr></table></td></tr></table><br><br> <td valign=top>
<table border="9" align=right class=main3>
<tr><th>Weights</th></tr><tr><td>
<LI>Pound</LI>
<LI>Pounds</LI>
<LI>Lb</LI>
<LI>Lbs</LI><br><hr>
<LI>Kilogram</LI>
<LI>Kilograms</LI>
<LI>Kg</LI><br><br><hr> </td></tr></table></td></tr></table><br><br>
<font color="#FF5F00"> Type your request here :</font><BR><BR>
<form name = myform>
<input type = text name = req_string size = 50>
<input type = button value = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/">http://www.webdeveloper.com/forum/archive/index.php/</a><!-- m -->"Convert" onclick = convert() class=button><br>
</form>
</BLOCKQUOTE></td></tr></table>
</body>
</html>