0% found this document useful (0 votes)
5 views4 pages

Js Cal Explain

The document describes three functions used in an HTML calculator: clearDisplay() to clear the display, jaa(param) to add button values to the input, and calculateResult() to evaluate mathematical expressions. It explains how the display is manipulated using JavaScript and how background colors change based on actions. Additionally, it mentions error handling during calculations and the use of the onclick attribute for button functionality.

Uploaded by

Bobby
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Js Cal Explain

The document describes three functions used in an HTML calculator: clearDisplay() to clear the display, jaa(param) to add button values to the input, and calculateResult() to evaluate mathematical expressions. It explains how the display is manipulated using JavaScript and how background colors change based on actions. Additionally, it mentions error handling during calculations and the use of the onclick attribute for button functionality.

Uploaded by

Bobby
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 4

In this code I use 3 function to add functionality to

HTML calculator:-
1. clearDisplay() = for clearing display after
calculation.
2. jaa(param)=for adding a value as param means
parameter which decide the button value &&& fix
the value of button.
3. calculateResult() = this function use to calculate all
sums.

OKAY??
 First function shown in figure describe how we enter the value
to our input by button

 document.getElementById('display').value += value;

In this line we selecting display(input box) by id which


Append/concat or assign value to input box.

Second line use for add bgcolor to display when we click


On button which have jaa() function

Note: here is a onclick attribute which use to access or perform js functions to our
buttons okay??
 Second function shown in figure describe how we clear the value
from our input box.
•Clears the content of the display by setting its value to an
empty string.

•Resets the background color to white. Whenever click to


clearDisplay() functions button.

This button have clear function

<button
onclick="clearDisplay()">C</button>
•Evaluates the mathematical expression in the value of the display element using eval().

•If successful, updates the display with the result and changes the background color to green.
•If there is an error during evaluation (e.g., invalid syntax), sets the display to "Error" and changes the background
color to red.

<button
onclick="calculateResult()">=</button>

 Third function shown in figure describe how we clear the value from our
input box.

You might also like