...

View Full Version : Using the Eval function.



prezbedard
08-19-2002, 08:35 PM
The eval function is supposed to evaluate a mathmatical expression?

So if I have a text box and the user enters say 2+2 how would I code the eval function so it will return the result correctly.
I have been trying to do this but I can not get it to work correctly.

Thanks

joh6nn
08-19-2002, 09:04 PM
var mathExpression = "2+2";
var mathAnswer;
mathAnswer = eval(mathExpression);
alert(mathAnswer);

get it?

prezbedard
08-19-2002, 09:11 PM
I get it. Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum