Showing Calculated fields in the form

Discussion in 'ASP General' started by Jack, Dec 14, 2004.

  1. Jack

    Jack Guest

    Hi,
    I have a asp input form of a financial report. Here most of the fields are
    text boxes where the user need to input the values corresponding to an item.
    However, there are few items which are calcuated field. Prior to submission
    of the information, I would like the user to know what the calculated field
    be (based on the information input in text boxes) before submission of the
    form. Is there any way to display the calculated value before submission in
    ASP? I appreciate in any help. Thanks.
    Jack, Dec 14, 2004
    #1
    1. Advertising

  2. If you want to do it ~before~ submission, you'll need to use client-side
    script to calculate the values, i.e. JavaScript, which is off-topic here of
    course. But, as a sample:

    <form name="formName">
    <input name="a" type="text" onchange="hyp();" />
    <input name="b" type="text" onchange="hyp();" />
    <input name="c" type="text" />

    </form>
    <script type="text/javascript">
    function hyp() {
    var a = document.formName.a.value;
    var b = document.formName.b.value;
    if (a!='' && b!='') {
    var c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2));
    if(!isNaN(c)) { document.formName.c.value=c; }
    }
    }
    </script>

    Ray at work

    "Jack" <> wrote in message
    news:...
    > Hi,
    > I have a asp input form of a financial report. Here most of the fields are
    > text boxes where the user need to input the values corresponding to an

    item.
    > However, there are few items which are calcuated field. Prior to

    submission
    > of the information, I would like the user to know what the calculated

    field
    > be (based on the information input in text boxes) before submission of the
    > form. Is there any way to display the calculated value before submission

    in
    > ASP? I appreciate in any help. Thanks.
    Ray Costanzo [MVP], Dec 14, 2004
    #2
    1. Advertising

  3. Jack

    mirza i Guest

    or you could:

    assuming that let's say totvalue = txtbox2 + txtbox1

    on updating either txtbox2 or txtbox1 call another asp page passing the two
    vars and adding them up in that page and then
    passing the three vars back into your original page.

    txtbox1 would then be the var1
    txtbox2 would then be the var2

    and

    in the html show the totvalue wherever you want to show it.

    also,
    at the start of the page have, if var1= "" then | var1=0 | end if
    similarly for var2

    using this method your data is more secure as all the calcs are done on the
    server.

    mirzai



    "Jack" <> wrote in message
    news:...
    > Hi,
    > I have a asp input form of a financial report. Here most of the fields are
    > text boxes where the user need to input the values corresponding to an
    > item.
    > However, there are few items which are calcuated field. Prior to
    > submission
    > of the information, I would like the user to know what the calculated
    > field
    > be (based on the information input in text boxes) before submission of the
    > form. Is there any way to display the calculated value before submission
    > in
    > ASP? I appreciate in any help. Thanks.



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.815 / Virus Database: 554 - Release Date: 14/12/2004
    mirza i, Dec 14, 2004
    #3
  4. Jack

    Jack Guest

    Thanks to both Ray and Mirza for giving insight to the resolution of problem.
    I need to do a test page to check on the above two concepts before
    implementing in the finalcial application. Regards.

    "mirza i" wrote:

    > or you could:
    >
    > assuming that let's say totvalue = txtbox2 + txtbox1
    >
    > on updating either txtbox2 or txtbox1 call another asp page passing the two
    > vars and adding them up in that page and then
    > passing the three vars back into your original page.
    >
    > txtbox1 would then be the var1
    > txtbox2 would then be the var2
    >
    > and
    >
    > in the html show the totvalue wherever you want to show it.
    >
    > also,
    > at the start of the page have, if var1= "" then | var1=0 | end if
    > similarly for var2
    >
    > using this method your data is more secure as all the calcs are done on the
    > server.
    >
    > mirzai
    >
    >
    >
    > "Jack" <> wrote in message
    > news:...
    > > Hi,
    > > I have a asp input form of a financial report. Here most of the fields are
    > > text boxes where the user need to input the values corresponding to an
    > > item.
    > > However, there are few items which are calcuated field. Prior to
    > > submission
    > > of the information, I would like the user to know what the calculated
    > > field
    > > be (based on the information input in text boxes) before submission of the
    > > form. Is there any way to display the calculated value before submission
    > > in
    > > ASP? I appreciate in any help. Thanks.

    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system (http://www.grisoft.com).
    > Version: 6.0.815 / Virus Database: 554 - Release Date: 14/12/2004
    >
    >
    >
    Jack, Dec 14, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=

    calculated column in datagrid question

    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=, Mar 23, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    574
    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=
    Mar 23, 2005
  2. samir
    Replies:
    0
    Views:
    557
    samir
    Dec 21, 2005
  3. Craig L. Taylor

    Offset not calculated properly

    Craig L. Taylor, Mar 4, 2005, in forum: Java
    Replies:
    0
    Views:
    323
    Craig L. Taylor
    Mar 4, 2005
  4. MS
    Replies:
    8
    Views:
    111
    Dr John Stockton
    Jan 23, 2004
  5. Replies:
    23
    Views:
    449
    Tim Streater
    Dec 18, 2013
Loading...

Share This Page