Hello all,
I’m having some issues getting my table to appear directly over another table after clicking the submit button using document.write in the function. Also, I need my submit button to be aligned in the middle of the
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Table</title>
<script src="app.js" type="text/javascript"></script>
</head>
<body>
<!--table 1-->
<table id="tableOne" border="1">
<tr>
<th>
Full Name:
</th>
<td>
<input type="text" name="FullName" id="fname">
</td>
</tr>
<th>
Member ID:
</th>
<td>
<input type="text" name="MemberID" id="mid1">
</td>
<tr>
<th>
Gender:
</th>
<td>
<input type="radio" name="Male" id="m1" value="Male">
<label for="m1">Male</label>
<input type="radio" name="Male" id="f1" value="Female">
<label for="f1">Female</label>
</td>
</tr>
<tr>
<th>
Height:
</th>
<td>
<input type="text" name="Height" id="h1">
</td>
</tr>
<th>
Weight:
</th>
<td>
<input type="text" name="Weight" id="w1">
</td>
</table>
<!--processes the acceptInput()-->
<button id="push" onclick="acceptInput()">Send it!</button>
<br>
<br>
<!--table 2-->
<table id="resultTable" border="1">
<tr>
<th>
Full Name:
</th>
<td>
<input type="text" name="FullName2" id="fname2" readonly>
</td>
</tr>
<th>
Member ID:
</th>
<td>
<input type="text" name="MemberID2" id="mid2">
</td>
<tr>
<th>
Gender:
</th>
<td>
<input type="text" name="Male2" id="m2"value="" readonly>
<input type="hidden" name="Male2" id="f2" value="1" readonly>
</td>
</tr>
<tr>
<th>
Height:
</th>
<td>
<input type="text" name="Height2" id="h2"readonly>
</td>
</tr>
<th>
Weight:
</th>
<td>
<input type="text" name="Weight2" id="w2" readonly>
</td>
<tr>
<th>
Ideal Weight:
</th>
<td>
<input type="text" name="IdealWeight" id="iw" readonly>
</td>
</tr>
</table>
</body>
</html>
var bm1=false;
var bf1=true;
var oneh=100;
var fullname;
var mid;
var height;
var sum2;
var sum1;
var weight;
var iweight;
//sum1 and sum2 arithemtic based on gender
function calculateResult(height)
{
sum1=(height-oneh)- (height-oneh) * 0.1;
sum2=(height-oneh) - (height-oneh)* 0.15;
if (getGender()){
return sum2;
}
else{
return sum1 ;
}
}
function getGender(){
return document.getElementById('f1').checked;
}
//Takes data from above table into below
function acceptInput()
{
fullname=document.getElementById('fname').value;
mid=document.getElementById('mid1').value;
bm1=document.getElementById('m1').boolValue;
bf1=document.getElementById('f1').boolValue;
height=parseInt(document.getElementById('h1').value);
weight=parseInt(document.getElementById('w1').value);
document.getElementById('fname2').value = fullname;
document.getElementById('mid2').value = mid;
setMaleFemale();
document.getElementById('h2').value = height;
document.getElementById('w2').value = weight;
document.getElementById('iw').value = calculateResult(weight);
}
//Checks for radio-button selection.
function setMaleFemale(gender){
if(getGender()){
document.getElementById('m2').value = "Female";
}else {
document.getElementById('m2').value = "Male";
}
}