Assume that you want to place an order in a different currency and you are looking at a currency exchange web page. Before you place the order you may need to do some calculation. Would it not be nice if such a page had a standard calculator? Similarly, some scientific articles on the Internet require the reader to do some calculation to fully appreciate the topic. Would it not be nice if such a page had a scientific calculator? This is a six-part series which shows you how to design a calculator for your web page.
The ID of the Input Text Control is "CI1." This control does not respond to any event and so has no event attribute. This control is given the readonly attribute.
The Buttons
Each button has the onclick event. When a button is clicked, a function is called with the ID of the button passed as an argument. All of the number buttons, including the point, the +/- and the RM buttons, call the same function; the ID determines what number should be displayed (or what should happen). Each of the other buttons calls another function, passing its ID as an argument. The ID determines what action should take place.
Glance through the above code and note the IDs and event attributes. Note the line break elements, which demarcate the lines of the controls in the DIV element. I have not shown the code for the functions in this part of the series. I will show that in the next part. What I wanted you to understand in this part are the main objectives in the project.
You should now know the controls you need for the standard calculator. You should also know how to fit them in a DIV element. You should also know how to make the calculator appear and disappear; take note of the layering (z-index) and Display features.
In the next parts of the series I will explain what happens when you click a button and most importantly, what happens when you click the equal sign (Enter button). After that we shall go into the operation of a scientific calculator.
We have come to the end of this part of the series. We continue in the next part. Courage!
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.