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

Js Cal Explain

The document describes three functions used in an HTML calculator: clearDisplay() for clearing the display, jaa(param) for adding values to the input, and calculateResult() for evaluating mathematical expressions. It explains how to manipulate the display element and handle button clicks to perform these functions. The document also notes the use of background color changes to indicate different states of the calculator display.

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 PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Js Cal Explain

The document describes three functions used in an HTML calculator: clearDisplay() for clearing the display, jaa(param) for adding values to the input, and calculateResult() for evaluating mathematical expressions. It explains how to manipulate the display element and handle button clicks to perform these functions. The document also notes the use of background color changes to indicate different states of the calculator display.

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 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>

➢ Second function shown in figure describe how we clear the value from
our input box.

You might also like