[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Simple Calculation?

Posted on 2001-06-22
2
Medium Priority
?
138 Views
Last Modified: 2010-04-07
How can I have say 10 fields on my web page in which the user inputs some numbers and then a field at the bottom adds them all together?

So simple???!?!?
0
Comment
Question by:JGWY
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
daniel_c earned 200 total points
ID: 6219098
Is this what you want? Just a simple example:

<html>
<head>
<script language=Javascript>
     function addValue(sVal)
     {
          var iTotal;
          if (!isNaN(sVal)) {
               iTotal = parseInt(document.form1.txtTotal.value);
               iTotal += parseInt(sVal);                    
          }
          else {
               iTotal = parseInt(document.form1.txtTotal.value);
          }
          document.form1.txtTotal.value = iTotal;
          //alert(document.form1.txtTotal.value);
     }
</script>
</head>
<body>
<form name=form1>
Number 01: <input type=text name=txtNumber01 size=3 maxlength=3 onBlur="addValue(this.value)" value="0"><br>
Number 02: <input type=text name=txtNumber02 size=3 maxlength=3 onBlur="addValue(this.value)" value="0"><br>
Number 03: <input type=text name=txtNumber03 size=3 maxlength=3 onBlur="addValue(this.value)" value="0"><br>
Number 04: <input type=text name=txtNumber04 size=3 maxlength=3 onBlur="addValue(this.value)" value="0"><br>
Number 05: <input type=text name=txtNumber05 size=3 maxlength=3 onBlur="addValue(this.value)" value="0"><br>
Number 06: <input type=text name=txtNumber06 size=3 maxlength=3 onBlur="addValue(this.value)" value="0"><br>
Number 07: <input type=text name=txtNumber07 size=3 maxlength=3 onBlur="addValue(this.value)" value="0"><br>
Number 08: <input type=text name=txtNumber08 size=3 maxlength=3 onBlur="addValue(this.value)" value="0"><br>
Number 09: <input type=text name=txtNumber09 size=3 maxlength=3 onBlur="addValue(this.value)" value="0"><br>
Number 10: <input type=text name=txtNumber10 size=3 maxlength=3 onBlur="addValue(this.value)" value="0"><br>
<hr size=1>
Total    : <input type=text name=txtTotal size=3 maxlength=3 value="0">
</form>
</body>
</html>


Hope this helps!

^_^
0
 

Author Comment

by:JGWY
ID: 6219385
Spot on, may come back to you for variations on this if I need to. Cheers
0

Featured Post

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question