I'm making a simple calculator written in HTML, CSS, JS, and PHP. It looks like this:
I use JS to get the user input and PHP to do the calculations and output the results.
I want to clear the result when the user clicks on any button.
I've tried ob
functions in PHP but this prevents any results from showing up in the first place.
I've tried resetting the innerHTML
of the div with JS with no luck.
Try something along the lines of creating a variable to indicate a new calculation and using it to clear the screen when a number is pressed.
Do a calculation
Display the answer
newCalculation = true;
Press a number (for the next calculation)
if(newCalculation == true){
Clear the screen and display the number
newCalculation = false;
}
Press = and display the answer then do it all again.