Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8175539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:49:11+00:00 2026-06-06T22:49:11+00:00

I have got a form into which information is entered, and a drop down

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:49:13+00:00Added an answer on June 6, 2026 at 10:49 pm
    var sexValue = sexfactor == "M" ? 1.23 : 1.04;
    

    Should be:

    var sexValue = sexfactor == "M" ? 1.23m : 1.04m;
    

    The ‘m’ after the two values makes it obvious that you are dealing with decimals.

    ===========================================

    Here is my version:

    @{
        ViewBag.Title = "TestButton";
    
    
        var totalMessage = "";
        if (IsPost)
        {
            var age = Request["frmage"].AsInt();
            var weight = Request["frmweight"].AsDecimal();
            var SerCre = Request["frmSerCre"].AsDecimal();
            var sexfactor = Request["frmGender"];
    
            var sexValue = sexfactor == "M" ? 1.23m : 1.04m;
    
            var total = Convert.ToDecimal((((140 - age) * weight) * sexValue) / SerCre);
            totalMessage = "Calculated creatinine clearance (ml/min)= " + (total + 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>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have form in drupal which uploads images and has got few checkboxes in
Is it possible to paqckage multiple rpms into one file. I have got two
I have a website, and in the Contact section I have a form which
I have got a form that posts values to a page in a wizard.
I have got a the following problem: I have got multi-step form where in
We have got an extjs 3.1.1 form with file upload field ( http://www.extjs.com/deploy/dev/examples/form/file-upload.html from
I have got 2 DropDownList s on my Form and 1 GridView . I
I have got a textbox on a form with a method being called from
I have this quick question, i have got the username variable from a form
I am generating a rss(xml) output form a php file. I have got a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.