Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Showing Calculated fields in the form

Reply
Thread Tools

Showing Calculated fields in the form

 
 
Jack
Guest
Posts: n/a
 
      12-14-2004
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.
 
Reply With Quote
 
 
 
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      12-14-2004
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:4F1DCFCE-9E18-4CEB-B5C5-...
> 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.



 
Reply With Quote
 
 
 
 
mirza i
Guest
Posts: n/a
 
      12-14-2004
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:4F1DCFCE-9E18-4CEB-B5C5-...
> 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


 
Reply With Quote
 
Jack
Guest
Posts: n/a
 
      12-14-2004
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:4F1DCFCE-9E18-4CEB-B5C5-...
> > 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
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how this is calculated "BW Util has exceeded the threshold value of 60%,The present value is 62% -" philip007 Cisco 1 01-31-2006 03:09 PM
urg-how to sort datagrid having calculated column samir ASP .Net 0 12-21-2005 02:41 AM
calculated column in datagrid question =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?= ASP .Net 3 03-23-2005 06:55 PM
Offset not calculated properly Craig L. Taylor Java 0 03-04-2005 12:11 AM
Calculated form field numerical amount IF ELSE MS Javascript 8 01-23-2004 01:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57