I am making a calculator which will work as follows:
the user will put his calculation in a textbox eg: 2+4+5; then the whole string will be converted to integer and calculate the numbers and display the result:11;.
My code is as follows:
Script:
function solve() {
problem = parseInt(document.getElementById('prob'));
ans = document.getElementById('ansspace');
ans.innerHTML = problem
}
HTML:
<input type="text" id="prob">
<br> <input type="button" id="add" value="Add" onclick="solve()"> <br>
<p id='ansspace'></p>