I have created a form named 'FrontPage_Form1' I have three fields called
'Amount1' , 'Amount2' and 'Amount3'. What I want to do is have a field that
adds the three amounts as they are entered and show the value in a field
called 'Total'. This form saves to an Access database.

Is there a simple script that I can add to the page to do this and where
abouts do I add it in the html code. I have searched many of the FP support
sites but none have a simple script to accomplish this task

Thanks
Graham

Re: Maths in FP Form by Lisa

Lisa
Thu Sep 25 18:51:28 CDT 2003

Here's a very simple script that should work for you. I've matched the
casing for form and control names, so you should be able to paste it into
your web page without too many modifications, if any. Put it in the HEAD
section of the page on which the form is located.

<script>
function CalculateTotal()
{
var fm = document.FrontPage_Form1;
var amt1 = document.FrontPage_Form1.Amount1;
var amt2 = document.FrontPage_Form1.Amount2;
var amt3 = document.FrontPage_Form1.Amount3;
var ttl = document.FrontPage_Form1.Total;
var iAmt1 = 0;
var iAmt2 = 0;
var iAmt3 = 0;

if (amt1.value != "")
{iAmt1 = parseInt(amt1.value);}
if (amt2.value != "")
{iAmt2 = parseInt(amt2.value);}
if (amt3.value != "")
{iAmt3 = parseInt(amt3.value);}

ttl.value = iAmt1 + iAmt2 + iAmt3;
}
</script>

Then you need to put the following event handler in each of the Amount
control in the form

onchange=CalculateTotal();

So that the control looks like

<input type="text" name="Amount1" onchange=CalculateTotal();>

Once you've done that, preview in the browser and enter numbers into the
amount controls. The number in the total box should change everytime you
change one of the amount numbers.

--
Lisa Wollin
Programmer Writer
Microsoft Corporation
"Graham Skaines" <graham@indivisualqld.com> wrote in message
news:OxSpOU2gDHA.3104@TK2MSFTNGP11.phx.gbl...
> I have created a form named 'FrontPage_Form1' I have three fields called
> 'Amount1' , 'Amount2' and 'Amount3'. What I want to do is have a field
that
> adds the three amounts as they are entered and show the value in a field
> called 'Total'. This form saves to an Access database.
>
> Is there a simple script that I can add to the page to do this and where
> abouts do I add it in the html code. I have searched many of the FP
support
> sites but none have a simple script to accomplish this task
>
> Thanks
> Graham
>
>



Re: Maths in FP Form by Stefan

Stefan
Thu Sep 25 12:45:07 CDT 2003

See http://www.developer.irt.org/script/form.htm
--
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.net-sites.com/sitebuilder/newsgroups.asp
_____________________________________________


"Graham Skaines" <graham@indivisualqld.com> wrote in message news:OxSpOU2gDHA.3104@TK2MSFTNGP11.phx.gbl...
| I have created a form named 'FrontPage_Form1' I have three fields called
| 'Amount1' , 'Amount2' and 'Amount3'. What I want to do is have a field that
| adds the three amounts as they are entered and show the value in a field
| called 'Total'. This form saves to an Access database.
|
| Is there a simple script that I can add to the page to do this and where
| abouts do I add it in the html code. I have searched many of the FP support
| sites but none have a simple script to accomplish this task
|
| Thanks
| Graham
|
|



Re: Maths in FP Form by Graham

Graham
Fri Sep 26 07:23:17 CDT 2003

Thanks so much for your help - Will give it a go.

Thanks Again
Graham


"Lisa Wollin (Microsoft)" <lisawoll@online.microsoft.com> wrote in message
news:%23cZ8y$7gDHA.1740@tk2msftngp13.phx.gbl...
> Here's a very simple script that should work for you. I've matched the
> casing for form and control names, so you should be able to paste it into
> your web page without too many modifications, if any. Put it in the HEAD
> section of the page on which the form is located.
>
> <script>
> function CalculateTotal()
> {
> var fm = document.FrontPage_Form1;
> var amt1 = document.FrontPage_Form1.Amount1;
> var amt2 = document.FrontPage_Form1.Amount2;
> var amt3 = document.FrontPage_Form1.Amount3;
> var ttl = document.FrontPage_Form1.Total;
> var iAmt1 = 0;
> var iAmt2 = 0;
> var iAmt3 = 0;
>
> if (amt1.value != "")
> {iAmt1 = parseInt(amt1.value);}
> if (amt2.value != "")
> {iAmt2 = parseInt(amt2.value);}
> if (amt3.value != "")
> {iAmt3 = parseInt(amt3.value);}
>
> ttl.value = iAmt1 + iAmt2 + iAmt3;
> }
> </script>
>
> Then you need to put the following event handler in each of the Amount
> control in the form
>
> onchange=CalculateTotal();
>
> So that the control looks like
>
> <input type="text" name="Amount1" onchange=CalculateTotal();>
>
> Once you've done that, preview in the browser and enter numbers into the
> amount controls. The number in the total box should change everytime you
> change one of the amount numbers.
>
> --
> Lisa Wollin
> Programmer Writer
> Microsoft Corporation
> "Graham Skaines" <graham@indivisualqld.com> wrote in message
> news:OxSpOU2gDHA.3104@TK2MSFTNGP11.phx.gbl...
> > I have created a form named 'FrontPage_Form1' I have three fields called
> > 'Amount1' , 'Amount2' and 'Amount3'. What I want to do is have a field
> that
> > adds the three amounts as they are entered and show the value in a field
> > called 'Total'. This form saves to an Access database.
> >
> > Is there a simple script that I can add to the page to do this and where
> > abouts do I add it in the html code. I have searched many of the FP
> support
> > sites but none have a simple script to accomplish this task
> >
> > Thanks
> > Graham
> >
> >
>
>



Re: Maths in FP Form by Graham

Graham
Fri Sep 26 21:55:28 CDT 2003

Works well, but being $ amounts it does not show the cents only adds the
full dollars

Thanks
Graham

"Lisa Wollin (Microsoft)" <lisawoll@online.microsoft.com> wrote in message
news:%23cZ8y$7gDHA.1740@tk2msftngp13.phx.gbl...
> Here's a very simple script that should work for you. I've matched the
> casing for form and control names, so you should be able to paste it into
> your web page without too many modifications, if any. Put it in the HEAD
> section of the page on which the form is located.
>
> <script>
> function CalculateTotal()
> {
> var fm = document.FrontPage_Form1;
> var amt1 = document.FrontPage_Form1.Amount1;
> var amt2 = document.FrontPage_Form1.Amount2;
> var amt3 = document.FrontPage_Form1.Amount3;
> var ttl = document.FrontPage_Form1.Total;
> var iAmt1 = 0;
> var iAmt2 = 0;
> var iAmt3 = 0;
>
> if (amt1.value != "")
> {iAmt1 = parseInt(amt1.value);}
> if (amt2.value != "")
> {iAmt2 = parseInt(amt2.value);}
> if (amt3.value != "")
> {iAmt3 = parseInt(amt3.value);}
>
> ttl.value = iAmt1 + iAmt2 + iAmt3;
> }
> </script>
>
> Then you need to put the following event handler in each of the Amount
> control in the form
>
> onchange=CalculateTotal();
>
> So that the control looks like
>
> <input type="text" name="Amount1" onchange=CalculateTotal();>
>
> Once you've done that, preview in the browser and enter numbers into the
> amount controls. The number in the total box should change everytime you
> change one of the amount numbers.
>
> --
> Lisa Wollin
> Programmer Writer
> Microsoft Corporation
> "Graham Skaines" <graham@indivisualqld.com> wrote in message
> news:OxSpOU2gDHA.3104@TK2MSFTNGP11.phx.gbl...
> > I have created a form named 'FrontPage_Form1' I have three fields called
> > 'Amount1' , 'Amount2' and 'Amount3'. What I want to do is have a field
> that
> > adds the three amounts as they are entered and show the value in a field
> > called 'Total'. This form saves to an Access database.
> >
> > Is there a simple script that I can add to the page to do this and where
> > abouts do I add it in the html code. I have searched many of the FP
> support
> > sites but none have a simple script to accomplish this task
> >
> > Thanks
> > Graham
> >
> >
>
>



Re: Maths in FP Form by Stefan

Stefan
Sat Sep 27 03:24:45 CDT 2003

Use "parseFloat" for a floating point # instead of "parseInt" for an integer value in the script

--
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.net-sites.com/sitebuilder/newsgroups.asp
_____________________________________________


"Graham Skaines" <graham@indivisualqld.com> wrote in message news:%23EUYNLKhDHA.3616@TK2MSFTNGP11.phx.gbl...
| Works well, but being $ amounts it does not show the cents only adds the
| full dollars
|
| Thanks
| Graham
|
| "Lisa Wollin (Microsoft)" <lisawoll@online.microsoft.com> wrote in message
| news:%23cZ8y$7gDHA.1740@tk2msftngp13.phx.gbl...
| > Here's a very simple script that should work for you. I've matched the
| > casing for form and control names, so you should be able to paste it into
| > your web page without too many modifications, if any. Put it in the HEAD
| > section of the page on which the form is located.
| >
| > <script>
| > function CalculateTotal()
| > {
| > var fm = document.FrontPage_Form1;
| > var amt1 = document.FrontPage_Form1.Amount1;
| > var amt2 = document.FrontPage_Form1.Amount2;
| > var amt3 = document.FrontPage_Form1.Amount3;
| > var ttl = document.FrontPage_Form1.Total;
| > var iAmt1 = 0;
| > var iAmt2 = 0;
| > var iAmt3 = 0;
| >
| > if (amt1.value != "")
| > {iAmt1 = parseInt(amt1.value);}
| > if (amt2.value != "")
| > {iAmt2 = parseInt(amt2.value);}
| > if (amt3.value != "")
| > {iAmt3 = parseInt(amt3.value);}
| >
| > ttl.value = iAmt1 + iAmt2 + iAmt3;
| > }
| > </script>
| >
| > Then you need to put the following event handler in each of the Amount
| > control in the form
| >
| > onchange=CalculateTotal();
| >
| > So that the control looks like
| >
| > <input type="text" name="Amount1" onchange=CalculateTotal();>
| >
| > Once you've done that, preview in the browser and enter numbers into the
| > amount controls. The number in the total box should change everytime you
| > change one of the amount numbers.
| >
| > --
| > Lisa Wollin
| > Programmer Writer
| > Microsoft Corporation
| > "Graham Skaines" <graham@indivisualqld.com> wrote in message
| > news:OxSpOU2gDHA.3104@TK2MSFTNGP11.phx.gbl...
| > > I have created a form named 'FrontPage_Form1' I have three fields called
| > > 'Amount1' , 'Amount2' and 'Amount3'. What I want to do is have a field
| > that
| > > adds the three amounts as they are entered and show the value in a field
| > > called 'Total'. This form saves to an Access database.
| > >
| > > Is there a simple script that I can add to the page to do this and where
| > > abouts do I add it in the html code. I have searched many of the FP
| > support
| > > sites but none have a simple script to accomplish this task
| > >
| > > Thanks
| > > Graham
| > >
| > >
| >
| >
|
|



Re: Maths in FP Form by MD

MD
Sat Sep 27 04:46:55 CDT 2003

Hi Graham,

Take a look at Form Calculator at
http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm
--
Mike -- FrontPage MVP '97-'02
J-Bots Plus 2002 End of Summer Sale You Save $20.00
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 mvpga@microsoft.com


"Graham Skaines" <graham@indivisualqld.com> wrote in message
news:OxSpOU2gDHA.3104@TK2MSFTNGP11.phx.gbl...
> I have created a form named 'FrontPage_Form1' I have three fields called
> 'Amount1' , 'Amount2' and 'Amount3'. What I want to do is have a field
that
> adds the three amounts as they are entered and show the value in a field
> called 'Total'. This form saves to an Access database.
>
> Is there a simple script that I can add to the page to do this and where
> abouts do I add it in the html code. I have searched many of the FP
support
> sites but none have a simple script to accomplish this task
>
> Thanks
> Graham
>
>



Re: Maths in FP Form by Graham

Graham
Sat Sep 27 06:27:45 CDT 2003

Thanks for the tip but now the value if ending in '0' is truncated to only
one number after the decimal point eg 21.6 instead of 21.60 - Any
suggestions

Thanks
Graham


"Stefan B Rusynko" <sbr_enjoy@hotmail.com> wrote in message
news:un7HRDNhDHA.1688@TK2MSFTNGP10.phx.gbl...
> Use "parseFloat" for a floating point # instead of "parseInt" for an
integer value in the script
>
> --
> _____________________________________________
> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
> "Warning - Using the F1 Key will not break anything!" (-;
> To find the best Newsgroup for FrontPage support see:
> http://www.net-sites.com/sitebuilder/newsgroups.asp
> _____________________________________________
>
>
> "Graham Skaines" <graham@indivisualqld.com> wrote in message
news:%23EUYNLKhDHA.3616@TK2MSFTNGP11.phx.gbl...
> | Works well, but being $ amounts it does not show the cents only adds the
> | full dollars
> |
> | Thanks
> | Graham
> |
> | "Lisa Wollin (Microsoft)" <lisawoll@online.microsoft.com> wrote in
message
> | news:%23cZ8y$7gDHA.1740@tk2msftngp13.phx.gbl...
> | > Here's a very simple script that should work for you. I've matched
the
> | > casing for form and control names, so you should be able to paste it
into
> | > your web page without too many modifications, if any. Put it in the
HEAD
> | > section of the page on which the form is located.
> | >
> | > <script>
> | > function CalculateTotal()
> | > {
> | > var fm = document.FrontPage_Form1;
> | > var amt1 = document.FrontPage_Form1.Amount1;
> | > var amt2 = document.FrontPage_Form1.Amount2;
> | > var amt3 = document.FrontPage_Form1.Amount3;
> | > var ttl = document.FrontPage_Form1.Total;
> | > var iAmt1 = 0;
> | > var iAmt2 = 0;
> | > var iAmt3 = 0;
> | >
> | > if (amt1.value != "")
> | > {iAmt1 = parseInt(amt1.value);}
> | > if (amt2.value != "")
> | > {iAmt2 = parseInt(amt2.value);}
> | > if (amt3.value != "")
> | > {iAmt3 = parseInt(amt3.value);}
> | >
> | > ttl.value = iAmt1 + iAmt2 + iAmt3;
> | > }