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

  • Home
  • SEARCH
  • 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 8312121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:03:18+00:00 2026-06-08T20:03:18+00:00

I have a form that you enter data into and it performs a calculation

  • 0

I have a form that you enter data into and it performs a calculation on it and give an answer. what i want to do is for it to keep the data in the form so that you can quickly repost so that you don’t have to change all the data. but I cant keep coming up with the error of it not existing, which I suppose is correct until the form has been posted!

@{
  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"]== "M" ? 1.23m : 1.04m;

        total =Convert.ToDecimal ((((140 - age)*weight)* sexfactor )/SerCre ) ;

        totalMessage =  total.ToString("0.00") + "(ml/min) ";
    }


}
<div class="memberRegistration">
<form method="post">

<p>
    <label class="formLabel">Age:</label> in years
    <input class="formTextField" type="text" name="frmAge" size="3" value="@age"/>
</p>
<p>
    <label class="formLabel">Weight:</label> in Kg (1st = 6.35kg)
    <input class="formTextField" type="text" name="frmWeight" value="@weight"/>
</p>
<p>
    <label class="formLabel">Serum Creatinine:</label> in μmol/L
    <input class="formTextField" type="text" name="frmSerCre" value="@SerCre"/>

</p>
<p>

<label class="fieldLabel">Gender:</label>
    <select name="frmGender" id="select" value="@sexfactor">
        <option value="M">Male</option>
        <option value="F">Female</option>
    </select>

</p>
<p><input type="submit" value="Calculate" /></p>
</form>
<p>Calculated creatinine clearance <b>@totalMessage</b></p>
</div>
  • 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-08T20:03:23+00:00Added an answer on June 8, 2026 at 8:03 pm

    Try this

    var age = 0;
    
        if (IsPost)
        {
            age = Request["frmage"].AsInt(0);
    
        }
    
    <input class="formTextField" type="text" name="frmAge" size="3" value="@age"/>
    

    But normally it would be better to use a model to hold your values, then in your controller you pass those values back again to your form

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that allows me to enter a user into my database.
I have a form where a user can enter the number of students that
I have a PHP form that enters data into my MySQL database. My primary
I have a form that performs calculations live as the user enters data. However,
I have a form that is supposed to store some of its data into
I have a form that allows users to enter a date of birth: ie:
I have a personal details form that allows you to enter a certain number
I have a TextBox in a Windows Form that allows a user to enter
I have a form that I want to be validated before showing it initially.
I have a textarea in a form that allows users to enter a list

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.