so, im kind of new at javascrip and a noobie at programming. im trying to implement a small server-hosted website that
implements a printer calculator. A printing calculator is a 20th century device that kept a running total of the numbers and the mathematical operators applied to them are (+, -, x, /). What I am trying to do with my site is to keep the running total and historical data (i.e. previous operations) for the past 20 operations and across session terminations (i.e. even if the user terminates the session closes the browser) until either 10 minutes have elapsed or until the user chooses to clear the
calculatorís history cache (or if the user changes IP address for example). Use of cookies is also allowed. So far i got the
calculator to run but still having trouble with the other parts.

here are my code for the calculator.

<HTML>
<HEAD>
<script language = javascript>



var oper=""
var num =""

function displaynum(n) {
document.form1.t1.value = document.form1.t1.value + n
}

function operator(op) {
oper = op
num= document.form1.t1.value
document.form1.t1.value = ""
}
//equal codes
function equals() {
doesthejob( eval(num) , eval(document.form1.t1.value ), oper)
}
//sub-function
function doesthejob(n1,n2, op) {
if (op == "+" )
document.form1.t1.value = n1 + n2
else if ( op == "-" )
document.form1.t1.value = n1- n2
else if (op == "*")
document.form1.t1.value = n1 * n2
else if (op =="/")
document.form1.t1.value = n1/n2
else if (op=="nCr" )
document.form1.t1.value = fact2(n1)/ fact2(n1 - n2) / fact2(n2)
else if (op =="nPr")
document.form1.t1.value = fact2(n1) / fact2(n1-n2)
}
//equal code ends

function fact2(n) {
if (errorchecking(n) ==false)
return

var answer = 1
for (i = n; i >=2; i--){
answer = answer*i
}
return answer
}

function fact() {
n = Number(document.form1.t1.value)
if (errorchecking(n) ==false)
return
var answer = 1
for (i = n; i >=2; i--){
answer = answer*i
}
document.form1.t1.value = answer
}

function errorchecking(n) {
if ( n < 0) {
alert("Number shouldn't be negative" )
return false
}
var mod = n%1
if (!mod ==0) {
alert("The number should be an integer" )
return false
}

document.writeln(form1.t1.value)

}


</script>

</HEAD>
<BODY>
<form name = form1>
<left><input type = text name = t1 value = "" size = 50><p>
<input type = button value = " 1 " name = b1 onclick = displaynum(1)>
<input type = button value = " 2 " name = b2 onclick = displaynum(2)>
<input type = button value = " 3 " name = b3 onclick = displaynum(3)>
<input type = button value = " + " name = bplus onclick = operator("+")
><br>

<input type = button value = " 4 " name = b4 onclick = displaynum(4)>
<input type = button value = " 5 " name = b5 onclick = displaynum(5)>
<input type = button value = " 6 " name = b6 onclick = displaynum(6)>
<input type = button value = " - " name = bminus onclick = operator("-")
> <br>

<input type = button value = " 7 " name = b7 onclick = displaynum(7)>
<input type = button value = " 8 " name = b8 onclick = displaynum(8)>
<input type = button value = " 9 " name = b9 onclick = displaynum(9)>
<input type = button value = " * " name = bmultiply
onclick = operator("*")> <br>

<input type = button value = " . " name = bdot onclick = displaynum(".")>
<input type = button value = " 0 " name = b0 onclick = displaynum(0)>
<input type = button value = " = " name= bequal onclick = equals()>
<input type = button value = " / " name = bdivide onclick = operator("/")
> <br>
<input type = button value = "clear" name = bclear onclick = reset()>

function myhistory()
{

}

</left>

</form>
</BODY>
</HTML>