I am new to asp.net mvc, I am creating a "fitness" web app that allows you to calculate BMI and BF% (percentage of body fat).
The user will see this:
<h1>Calculate</h1>
<h2>BMI</h2>
<form>
<table>
<tr>
<td align="right"><b>Weight:</b></td>
<td align="left"><input type="text" name="Weight" /></td>
</tr>
<tr>
<td align="right"><b>Height:</b></td>
<td align="left"><input type="text" name="Height" /></td>
</tr>
<tr>
<td align="right"><b>BMI:</b></td>
<td align="left"><input type="text" name="BMI" /></td>
</tr>
</table>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="button" value="Calculate" class="btn btn-default" onclick="location.href='<%: @Url.Action("CalculateBMI", "Measurements") %>'"/>
</div>
</div>
</form>
<h2>BF% (aproximated)</h2>
<p>(All the measurements must be taken at the narrowest point)</p>
<form>
<table>
<tr>
<td align="right"><b>Male</b></td>
<td align="left"><input type="radio" name="Waist" /></td>
<td align="center"><b>Female</b></td>
<td align="center"><input type="radio" name="Waist" /></td>
</tr>
<tr>
<td align="right"><b>Height:</b></td>
<td align="left"><input type="text" name="Height" /></td>
</tr>
<tr>
<td align="right"><b>Waist:</b></td>
<td align="left"><input type="text" name="Waist" /></td>
</tr>
<tr>
<td align="right"><b>Hip:</b></td>
<td align="left"><input type="text" name="Hip" /></td>
</tr>
<tr>
<td align="right"><b>Neck:</b></td>
<td align="left"><input type="text" name="Neck" /></td>
</tr>
<tr>
<td align="right"><b>BF%:</b></td>
<td align="left"><input type="text" name="BF%" /></td>
</tr>
</table>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="button" value="Calculate" class="btn btn-default" onclick="location.href='<%: @Url.Action("CalculateBF", "Measurements") %>'">
</div>
</div>
</form>
and when you click on the calculate button, the respective method will be called from the Measurements control:
public int CalculateBMI(int height, int weigth)
{
int BMI = height / (weigth * weigth);
return BMI;
}
public int CalculateBF(String gender,int height, int waist, int hip, int neck)
{
int bf;
if (gender.Equals("male"))
{
bf = ((495) / (int)(1.0324 - 0.19077 * Math.Log10(waist - neck) + 0.15456 * Math.Log10(height))) - 450;
return bf;
}
if (gender.Equals("female"))
{
bf = (int)((495) / (((1.29579 - 0.35004) * Math.Log10(waist + hip - neck) + 0.22100 * Math.Log10(height)) - 450)) - 450;
return bf;
}
return bf = 0;
}
But I have no idea how to make the values return to the input text of BMI and BF name and how to take the values of each input text to make the respective calculations.