HTML
  Home arrow HTML arrow Coding a Web Page Calculator
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

Coding a Web Page Calculator
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-03-11

    Table of Contents:
  • Coding a Web Page Calculator
  • Code Basics
  • The showNum() Function
  • The operator() Function
  • Explanation of the operator() Function

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Coding a Web Page Calculator


    (Page 1 of 5 )

    Welcome to the second part of a six-part series on how to build a calculator for your web page. In the previous part, we got into the basics of setting up the calculator's layout and what functions we want it to have. In this part, we will begin to code the functions.

    Pressing the Buttons

    You can either press a button by clicking it or by using the keyboard. Pressing by clicking requires you to give each button the onclick attribute. I included the onclick attribute for each button in the previous part of this series. I will address using the keyboard later in the series.

    In this part of the series, a button is pressed by clicking. When a button is clicked, the onclick event is triggered (calls a function). We shall look at the functions in this part of the series.

    Standard Calculator User Requirements

    In this section I explain the requirements from the user's point of view.

    • When the calculator is opened, the initial value in the display is zero.

    • As soon as you type a digit, the digit typed replaces the zero.

    • When a number appears on the display, clicking a digit joins the number on the display to the right.

    • When you click the +, -, X or / key, the next number typed replaces the number on the display. This should result in the +, -, X, or / operation.

    • When the equal sign button is clicked, the result replaces the number (group of digits) on the display.

    • When the M+ (store in memory) button is clicked, the number on the display is stored in memory. After this, clicking another digit replaces the number on the display.

    • You can erase the display by pressing a button.

    • When the equal sign is clicked, the operation (+, - X or /) combining the previous number on the display and the present number is evaluated. The result replaces the present number on the display.

    More HTML Articles
    More By Chrysanthus Forcha


     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek