As I was researching my current question this article seemed to be promising but I could not figure out for myself if it was the answer to my question. So if anyone could help my that would be terrific.
This is my Function:
function CalculateIMSUB(form) {
var Atext = form.input_1.value;
var Btext = form.input_2.value;
var val = form.val.value;
var A = eval(Atext);
var B = eval(Btext);
if (isNaN(A)) A = 0;
if (isNaN(B)) B = 0;
var answer = A - B;
form.Answer.value = answer;
}
This is my html:
<form>
<INPUT TYPE=TEXT name="input_1" SIZE=15>
<INPUT TYPE=TEXT name="input_2" SIZE=10>
<INPUT TYPE="button" VALUE="+" name="SubtractButton"
onclick="CalculateIMSUB(this.form)">
<INPUT TYPE=TEXT NAME="Answer" SIZE=12>
<input type="hidden" name="val" value="" />
</form>
My question:
Can I add with "/"
For instance currently, if you were to type 10 / 5 in the input 1 text field and click calculate you would have an answer of 2 in the Answer text field. Since as we all know 10 divided by 5 equals 2. I would like to be able to type 10/5 into the input 1 text field and receive an answer of 15 which would be the equivalent to 10+5. Your help is greatly appreciated, thank you and here is my jsFiddle.