Hey guys,
I’m new to Javascript and I’m trying to make a calculator without using the “eval” function. I am using jsbin.com to write my code and want to use the HTML and JavaScript partition, I got everything written in the HTML partition at the moment but i would like to have the JavaScript and the HTML seperated.Another problem is the “=” button, I have no idea how i can get the operation to work without eval, here is my code :
<FORM NAME=”Calculator”>
<TABLE BORDER=2>
<tr>
<td>
<input type = “text” Name = “Input” size =”15″>
</br>
</td>
</tr>
<tr>
<td>
<input type = “button” Name =
“seven” Value = “7” OnCLick = “Calculator.Input.value += ‘7’”>
<input type = “button” Name =
“eight” Value = “8” OnCLick = “Calculator.Input.value += ‘8’”>
<input type = “button” Name =
“nine” Value = “9”OnCLick = “Calculator.Input.value += ‘9’”>
<input type = “button” Name =
“divide” Value = “/”OnCLick = “Calculator.Input.value += ‘/'”>
</br>
<input type = “button” Name =
“four” Value = “4” OnCLick = “Calculator.Input.value += ‘4’” >
<input type = “button” Name =
“five” Value = “5” OnCLick = “Calculator.Input.value += ‘5’” >
<input type = “button” Name =
“six” Value = “6” OnCLick = “Calculator.Input.value += ‘6’” >
<input type = “button” Name =
“multiplication” Value = “*” OnCLick = “Calculator.Input.value += ‘
</br>
<input type = “button” Name =
“one” Value = “1” OnCLick = “Calculator.Input.value += ‘1’” >
<input type = “button” Name =
“two” Value = “2” OnCLick = “Calculator.Input.value += ‘2’” >
<input type = “button” Name =
“nine” Value = “3” OnCLick = “Calculator.Input.value += ‘3’” >
<input type = “button” Name =
“minus” Value = “-” OnCLick = “Calculator.Input.value += ‘-‘” >
</br>
<input type = “button” Name =
“zero” Value = “0” OnCLick = “Calculator.Input.value += ‘0’” >
<input type = “button” Name = “clear” Value = “c” OnCLick = “Calculator.Input.value = ‘ ‘ “>
<input type = “button” Name =
“equal” Value = “=”>
<input type = “button” Name =
“plus” Value = “+” OnCLick = “Calculator.Input.value += ‘+'” >
</td>
</tr>
Thanks in advance