Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 ASP calculator, how to create ?

views
     
TStpk1031
post Jan 12 2006, 12:38 PM, updated 20y ago

Casual
***
Junior Member
443 posts

Joined: Jan 2003
guys.. i'm tryin to create a calculator..

there's a field for me to type the formula

eg. 1 + 3 / (2*2)

so..when i submited the string

a = "1+3/(2*2)"

can i just straight convert the a to a math formula and give me the output

P/s : i wanna do something like the EXCEL, we can use type in the formula and get the instant output

thanx in advance
wangpr
post Jan 12 2006, 12:42 PM

Enthusiast
*****
Senior Member
758 posts

Joined: Jan 2003
From: Angel Heaven X
My suggestion website

Programming heaven

My diploma assignment also do calculator in Pascal.

I go modified the code from this website

Then get high marks

laugh.gif
erictioh84
post Jan 15 2006, 04:18 PM

On my way
****
Senior Member
638 posts

Joined: Dec 2004
From: Sri Kembangan | Penang


u can do it that way but not very easy. you must use a loop with stack to recognize those operators.
littleway
post Jan 22 2006, 11:54 PM

(!-.-)(tm)
******
Senior Member
1,658 posts

Joined: Jan 2003
From: JB/Cyberjaya


CODE

<html>

<head>
<title>Javascript Testor</title>
<script language="javascript">
function test()
{
document.writeln("This is the output: <br> <br> <hr> <br>");
var a;
a=prompt("Enter your calculations syntax eg: 1+2-1:","" );
document.write("<script language=javascript> var total; total="+a+";<\/script>");
if(total<99999999999999999999999999999999999999999999999&&total>-99999999999999999999999999999999999999999999)
{
document.write("You Have entered "+a+"<br>The answer..:"+total+" <br><br> <input type=submit value=Back onclick=history.back();>");
}
else
{
document.write("Invalid syntax or invalid arguement has been entered <br><br><input type=submit value=Back onclick=history.back();>");
}
}
</script>
</head>

<body>
Simple JavaScript Calculator. <br>
Eg: 3+5+6? enter 3+5+6 to get the answer.<br><br>
<input type="submit" value="start" onclick="test();">
<!-writen by (!-.-)™ Productions in 2004. For personal use purpose only.-!>
</body>
</html>


this is what i written in javascript few years ago... Do you mean a calculator like this?

 

Change to:
| Lo-Fi Version
0.0132sec    0.56    5 queries    GZIP Disabled
Time is now: 23rd December 2025 - 02:31 AM