Do you remember those old paper-tape adding machines that printed a strip as you entered numbers? In this article, I show you how to use simple Java Script to create a similar tape adding machine, except the tape is on your computer screen, not on paper.
Welcome to Bucaro TecHelp!

Welcome to Bucaro TecHelp!
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

[About BTH]  [User Agreement]  [Privacy Policy]  [Site Map]  [Contact Form]  [Advertise on BTH]  [News Feed]

Google
Web
This Site
Your Ad Here!
Your ad here for one full year, only $20. Send me your ad copy, up to six lines, I'll post it ASAP. After you inspect your ad online, you can pay through PayPal.
Click here for more information.

Easy Code for Screen Tape Adding Machine

Have you ever tried to add a column of numbers with a regular calculator? If you make a mistake, you have to start all over with the first number. Do you remember those old paper-tape adding machines that printed a strip as you entered numbers? In this article, I show you how to use simple Java Script to create a similar tape adding machine, except the tape is on your computer screen, not on paper.

To see a working example of the Screen Tape Adding Machine, click here.

As with all my other Easy Code articles, I'll give you cut-and-paste Java Script code and I'll explain the code in detail so that you can use it and modify it for your own requirements. You can put a copy of the Screen Tape Adding Machine on your own webpage for other's to use.

Before we design the complete Screen Tape Adding Machine, Let's do a few tutorial examples in order to learn the basics. For example, how do we get the contents of a text box and place it in another text box?

Place the code shown below in the <body> section of your webpage.

<form>
<input id="c1" type="text" onkeypress="return noenter()" /><br />
Total: <input id="total" type="text" />
</form>

This code creates a simple form with two text boxes. Each text box has a unique id attribute. The onkeypress event of the first text box executes a function named noenter. Place the code for the noenter function, shown below, in the <head> section of your webpage.

<script language="JavaScript">
function noenter() 
{
  if(window.event.keyCode == 13)
  {
    document.getElementById("total").value = document.getElementById("c1").value;
    return false; 
  }
}
</script>

This code creates a Java Script code block containing the noenter function. The if statement within the noenter function checks if the user pressed the keyboard [Enter] key. If they did, the document's getElementById method is used to retrieve the value property of the text box with the id c1, and place it in the value property of the text box with the id total.

-  Note that the noenter function returns false. This prevents the form from being submitted.

Web Design Sections

RSS Feed RSS Feed

Easy Java Script Code
Easy Java Script Timer Code
Easy Java Script Windows
Easy Rollovers
Easy Picture Transition Effects
Easy Moving Popup Code
Easy Slide Show Code
Easy Slide Show Code With Linked Slides
Slide Show with Different Size Images
Easy Picture Zoom Code
Easy Picture Panning Code
Easy Java Script Animation
Easy JavaScript Picture Selector Code
Easy Animated Banners with Java Script
Easy Java Script Form Validation
Easy Drag n Drop Code
Easy Graph Generating Code
Easy Code to Sort a Table by Column
Web Designer's Reference
Easy Fading Text Banner Code
Easy Expanding Banner Code
Calendars for Your Website
Date Picker For Your Web Site
Calculators For Your Web Site
Loan Payment Calculator
Length Units Converter
Body Mass Index
Fahrenheit to Celsius Converter
Decimal to Hexidecimal Converter
Easy Code for Screen Tape Adding Machine
Code for Java Script Circle⁄Sphere Calculator
Round a Float to 4 Digits to the Right of the Decimal Point
Make Your Own Graphical Digital Clock
Let Your Web site Visitors Set Font Size
How to Disable the Browser Back Button
Add More Bang to Your Content With Keyword Popup Menus
Put a Music Off Switch on Your Webpage
Java Script Random Password Generator
Password Protection Using Java Script
Replace Drop-down with Drag-and-drop
Submit Forms Without CGI
Code for a Less annoying Popup Window
Using the Java Script Array Object
Using the Java Script Date Object
Java Script Message Boxes
How to Shuffle the Deck With Java Script
Web Site Menus : Which Section Am I In?
How Far Did the User Scroll?
Where Did the User Click?
Four Ways to Use Java Script Event Handlers
Create Your Own Database Using Only Notepad : CDV

[Site User Agreement]  [Advertise on This site]  [Search This Site]  [Contact Form]
Copyright©2001-2007 Bucaro TecHelp P.O.Box 18952 Fountain Hills, AZ 85269