By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,122 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,122 IT Pros & Developers. It's quick & easy.

Showing Calculated fields in the form

P: n/a
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.
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <Ja**@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
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.

Jul 22 '05 #2

P: n/a
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" <Ja**@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
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
Jul 22 '05 #3

P: n/a
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" <Ja**@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
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

Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.