Calculations in Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was wondering if there is a way to do some basic arithmetic in forms. I
just want to do some very simple addition & multiplication without any custom
scripting or database back end. It will just be returned in an email for
manual processing.

Thanks - Jody
 
So, you want to obtain a specific result without having to do anything? It
should just happen?

Bob Lehmann
 
Noneed to be nasty. I am already overwhelmed

Bob Lehmann said:
So, you want to obtain a specific result without having to do anything? It
should just happen?

Bob Lehmann
 
Yes, there is, but not without Javascript.

It is not so intimidating as you might think. I had never written JS until a
few monhs ago, but it doesn't take long to learn how to so something
straightforward.

Perhaps if you give an example of what you want to do, I or another can
guide you.

--
Cheers,
Trevor L.
Website: http://tandcl.homemail.com.au
Noneed to be nasty. I am already overwhelmed


I choose Polesoft Lockspam to fight spam, and you?
http://www.polesoft.com/refer.html
 
This code works

<html>
<head>
<script type="text/javascript">
function add()
{ document.myForm['item3'].value= (+document.myForm['item1'].value)
+ (+document.myForm['item2'].value) }
</script>
</head>

<body>
<form name="myForm" action="">
<input type="text" name="item1" value="" size="1" maxlength="3">
<input type="text" name="item2" value="" size="1" maxlength="3">
<input type="text" name="item3" value="" size="1" maxlength="4">
<input type="button" value="Add" onClick="add()">
</form>
</body>
</html>

When you enter a number in the first box, then another in the second and
click on Add, the third shows the sum
You can manipulate the items in any other way e.g. subtracting, multiplying,
whatever
 
Do you really mean "without any scripting"? I ask because, if your web site
handles ASP, you can easily accomplish what you're after with *very* simple
code. See Microsoft's example at

http://support.microsoft.com/?scid=kb;en-us;823520&spid=2514&sid=138

Despite the title ("How to complete mathematical calculations on a form
before you send data to a database in FrontPage 2003"), you don't have to
write the output to a database to get the results, you can do whatever you
want with it.
 
Back
Top