I’m creating a calculator using the JS, I created buttons so it will concatenate the numbers before clicking the operators. I want to use the eval() funtion to compute the numbers in the textbox but the Operator signs must not be displayed in the textbox. So instead of 2 +1 the result in the textbox will be 2 >>operator button clicked >> 1 then the result would be 3 Any Help? Thanks
<div class = btnDiv1>
<button onclick="view('7')">7</button>
<button onclick="view('8')">8</button>
<button onclick="view('9')">9</button>
<button onclick="viewOp('*')">X</button>
<button onclick="btnClear('')">C</button>
<br>
<button onclick="view('4')">4</button>
<button onclick="view('5')">5</button>
<button onclick="view('6')">6</button>
<button onclick="viewOp('/')">/</button>
<button onclick="view('')">H</button>
<br>
<!-- Create another div so align equal sign buttons -->
<div class=btnDiv2>
<button onclick="view('1')">1</button>
<button onclick="view('2')">2</button>
<button onclick="view('3')">3</button>
<button onclick="viewOp('-')">-</button>
<button onclick="Compute(' ')" class = "btnCmp">=</button>
<br>
<button onclick="viewNegate('')">+/-</button>
<button onclick="view('0')">0</button>
<button onclick="view('.')">.</button>
<button onclick="viewOp('+')">+</button>
<br>
</div>
</div>
Javascript
// passed the value of the clicked button
function view(num)
{
document.getElementById("txtResult").value+= num;
}