Calculation on form

A

AC

I have a form that users are inputting data to. In this form there are three fields: oldcost, newcost and diffcost. What I would like to do is have the user enter the oldcost and newcost and have the form calculate the diffcost (newcost-oldcost) on the fly. The intent is to have them see it before they "submit" the form to the database. Can I do this?
 
D

David Berry

Yes. You can use JavaScript to do this. See
http://javascript.internet.com/calculators/ for examples.

--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net-sites.com/sitebuilder/
-----------------------------------

-----------------------------------
AC said:
I have a form that users are inputting data to. In this form there are
three fields: oldcost, newcost and diffcost. What I would like to do is
have the user enter the oldcost and newcost and have the form calculate the
diffcost (newcost-oldcost) on the fly. The intent is to have them see it
before they "submit" the form to the database. Can I do this?
 
M

MD WebsUnlimited.com

You may also wish to take a look at J-Bots Form Calculator at
http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm


--
Mike -- FrontPage MVP '97-'02
http://www.websunlimited.com
FrontPage Add-ins Since '97 2003 / 2002 / 2000 Compatible
----------------------------------------------------------------------------
--------------------
If you think I'm doing a good job, let MS know at [email protected]

AC said:
I have a form that users are inputting data to. In this form there are
three fields: oldcost, newcost and diffcost. What I would like to do is
have the user enter the oldcost and newcost and have the form calculate the
diffcost (newcost-oldcost) on the fly. The intent is to have them see it
before they "submit" the form to the database. Can I do this?
 
A

AC

I took your advice and cut and paste one of the calculators. Modified it to my needs, and added it to my page. Great news is, it even works. Bad news is, the rest of the page doesn't submit to the database now. In order to get the calculator portion to work, I had to nest that form within my overall form. I think this is where my folly is as now my submit button at the bottom of the page does nothing. Is there something special that is needed to nest forms?
 
K

Kevin Spencer

You can't nest forms. Period. You can put as many separate forms in a page
as you wish, however.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

AC said:
I took your advice and cut and paste one of the calculators. Modified it
to my needs, and added it to my page. Great news is, it even works. Bad
news is, the rest of the page doesn't submit to the database now. In order
to get the calculator portion to work, I had to nest that form within my
overall form. I think this is where my folly is as now my submit button at
the bottom of the page does nothing. Is there something special that is
needed to nest forms?
 
C

chris leeds

if you could post a url to the page in question you'll get a better answer.
I've recently used a little JavaScript to increment a number in a text box
on a shopping cart. I'm sure there is an easy way to do what you want.


AC said:
So... is there a way that I can do a calculation without a nested form so
that it calculates the third field (based on the first two) and 1) shows it
on the screen before it is submitted, and 2) submits the result into the
database with the rest of the information? I realize that I could probably
have the calculation occur on the same page, but outside of the main form,
but I want something slicker than that. I don't want someone to have to
jump back and forth within the same page.
 
A

AC

Can't publish publicly otherwise I would. I only have access to our intranet.

I did fix my problem though. I simply had the java calculator execute within the main form. Makes perfect sense.... now. Thanks for all your help.
 
K

Kevin Spencer

Hi AC,

JavaScript is not scoped to forms, but to a Browser instance. Therefore, you
can use JavaScript to make calculations regarding any HTML element in the
page, regardless of whether it resides in a form or not.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

AC said:
So... is there a way that I can do a calculation without a nested form so
that it calculates the third field (based on the first two) and 1) shows it
on the screen before it is submitted, and 2) submits the result into the
database with the rest of the information? I realize that I could probably
have the calculation occur on the same page, but outside of the main form,
but I want something slicker than that. I don't want someone to have to
jump back and forth within the same page.
 
Top