PC Review Forums Newsgroups Microsoft Word Microsoft Frontpage how to sum two form field values and display it in another field

Reply

how to sum two form field values and display it in another field

 
Thread Tools Rate Thread
Old 29-05-2007, 06:27 PM   #1
=?Utf-8?B?eW91c3NlZg==?=
Guest
 
Posts: n/a
Default how to sum two form field values and display it in another field


how to sum two form field values and display the result in another field
within the same form and pass it to another page as a hidden value
  Reply With Quote
Old 29-05-2007, 06:51 PM   #2
David Berry
Guest
 
Posts: n/a
Default Re: how to sum two form field values and display it in another field

You can use JavaScript to do this. See the free scripts at
http://javascript.internet.com under Math or Forms

--
David Berry
Microsoft MVP - FrontPage
FrontPage Support: http://www.frontpagemvps.com/
-----------------------------------
To assist you in getting the best answers for FrontPage support see:
http://www.frontpagemvps.com/FrontP...53/Default.aspx
-----------------------------------


"youssef" <youssef@discussions.microsoft.com> wrote in message
news:17DAA50F-124E-4F2E-BD87-6EE68AC00675@microsoft.com...
> how to sum two form field values and display the result in another field
> within the same form and pass it to another page as a hidden value



  Reply With Quote
Old 30-05-2007, 02:43 AM   #3
Trevor Lawrence
Guest
 
Posts: n/a
Default Re: how to sum two form field values and display it in another field


"David Berry" <dberry@mvps.org> wrote in message
news:%23c9RYGhoHHA.4960@TK2MSFTNGP02.phx.gbl...
> You can use JavaScript to do this. See the free scripts at
> http://javascript.internet.com under Math or Forms


Example:

<html>
<head>
<script type="text/javascript">
function calcform()
{
with (document.form1)
{ result.value = +number1.value + +number2.value}}
/*Note the extra + operator before each value. This is needed to convert the
value from a string to a number.*/
</script>
</head>
<body>

<form name="form1" action="">
Number 1 (enter number):<br />
<input type="text" id="number1" value="" size="40" /><br/>
Number 2 (enter value in dollars, e.g. 2.50) :<br />
<input type="text" id="number2" value="" size="40" /><br/>
Result:<br />
<input type="text" id="result" value="" size="40" /><br/>

<input type="button" id="Calculate" value="Calculate"
onclick="calcform()" />
<input type="reset" id="reset" value=" Clear "/>
</form>

</body>
</html>

Passing the value to another page is another matter.

If you need help to do this I can post the code for how I do it - it does
need some more JavaScript
--
Trevor Lawrence
Canberra
Microsoft MVP - FrontPage
MVP Web Site http://trevorl.mvps.org


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off