Blog > detail

Just my tiny mind

Javascript Calculator Using Eval

26-2-2012 Admin General 2 Comments

Javascript Calculator Using Eval

Eval is a function both resides in either Javascript or PHP. Eval is used for execute an argument. In this case, I ll try to share simple Javascript Calculator Using Eval. However, unlike other calculator that have buttons "1-9" and "*/+-", we dont have to put those buttons. Because this is a computer programs, so the user can input it from their keyboard.


This code is divided into 2 types. The Javascript code and the HTML form code.


Lets start with the HTML code first.



Last but not least, the Javascript as the engine of this program.


function calc(){

str = document.getElementById('query').value;

document.getElementById('result').value = eval(str);

}


In thid case, the eval will execute the string that inputed by you in the frist text box.


Our Javascript Calculator Using Eval here can calculate a simple calculation such as addition, reduction, multiplication and division. It also can handle parenthesis.


I wish this Javascript Calculator Using Eval is useful for you.


Good Luck


Related Post:


PHP Calculator Using Eval


Javascript Calculator Using Eval Javascript Calculator Using Eval Javascript Calculator Using Eval

Javascript Calculator Using Eval Javascript Calculator Using Eval Javascript Calculator Using Eval

Javascript Calculator Using Eval

word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word

Javascript Calculator Using Eval

Javascript Calculator Using Eval

Javascript Calculator Using Eval