RE: forms and javascript
by "Campbell, Rebecca" <Rebecca.Campbell(at)converg.com>
|
| Date: |
Fri, 2 Jun 2000 18:45:21 -0600 |
| To: |
"'John Jones'" <jtjones(at)davis.com>, hwg-techniques(at)hwg.org |
| |
todo: View
Thread,
Original
|
|
you're probably trying to add field1 + field1 and it's giving you something
weird like null or undefined... that happens when you try to add strings,
so you'll actually need to turn the contents of those fields into numbers.
the following will work:
x = document.formName.field1.value;
y = document.formName.field2.value;
z = parseFloat(x) + parseFloat(y);
document.formName.field3.value = z;
of course, there are tons of ways to do this, but that's a simple one that
should work (keep in mind that i haven't tested it, so if there's a slight
typo, i apologize.
hth,
rebecca
http://www.nerdygirl.com
-----Original Message-----
From: John Jones [mailto:jtjones(at)davis.com]
Sent: Friday, June 02, 2000 3:44 PM
To: hwg-techniques(at)hwg.org
Subject: forms and javascript
hi all,
I would like to tell a user the cost of how many widgets they've order
before they hit the submit button on a form. i assumed this would be easy
but I'm struggling. The client sells one item. The item cost $49.95, I'd
like to display the total cost, for example, 5 ($249.75). An easy script
would be appreciated.
--john
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA
This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.