I have got a form into which information is entered, and a drop down box for one section, which is male or female. (which gives out a value depending on that 1.23 or 1.04) which i now have working thanks to the wonderful minds on here! but still have an issue with the calculations with these figures.
@{
var total = 0m;
var totalMessage = "";
if (IsPost)
{
var age = Request["frmage"].AsInt(0);
var weight = Request["frmweight"].AsDecimal();
var SerCre = Request["frmSerCre"].AsDecimal();
var sexfactor = Request["frmGender"];
var sexValue = sexfactor == "M" ? 1.23 : 1.04;
total = Convert.ToDecimal ((((140 - age)*weight)* sexValue )/SerCre) ;
totalMessage = "Calculated creatinine clearance (ml/min)= " + total.ToString("0.00")+ sexValue ;
}
}
<form method="post">
<p>
<label for="text1">Age:</label>
<input type="text" name="frmAge" size="3" />Years
</p>
<p>
<label for="text2">Weight:</label>
<input type="text" name="frmWeight" />in Kg (1st = 6.35kg)
</p>
<p>
<label for="text3">Serum Creatinine:</label>
<input type="text" name="frmSerCre" />
μmol/L
</p>
<p>
<label for="text4">Gender:</label>
<select name="frmGender" id="select">
<option value="M">Male</option>
<option value="F">Female</option>
</select>
</p>
<p>
<input type="submit" value="Calculate" /></p>
</form>
<p>@totalMessage</p>
do i need to convert the decimal answers so that the code can see it as a decimal? even though they are already!
Should be:
The ‘m’ after the two values makes it obvious that you are dealing with decimals.
===========================================
Here is my version: