-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalcijava.js
52 lines (43 loc) · 1.47 KB
/
calcijava.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function formtable()
{
document.write("<table border=1>");
document.write('<tr><th><input type="text" size="5" id="result"/></td></tr>');
for(let i=1;i<=9;i++)
{
if(i%3==1)
{
document.write("<tr>");
}
document.write("<td>",i,"</td>");
if(i%3==0)
{
if(i==3)
{
document.write("<td><button onclick='show(/)'>/</button></td>");
}
if(i==6)
{
document.write("<td><button onclick='show(*)'>*</button></td>");
}
if(i==9) {
document.write("<td><button onclick='show(+)'>+</button></td>");
document.write("<tr><td><button onclick='show(value)'>-</button></td>")
document.write("<td><button onclick='show(.)'>.</button></td>");
document.write("<td><button onclick='show(0)'>0</button></td>");
document.write("<td><button onclick='cal()'>=</button></td></tr>");
}
}
}
}
function clr() {
document.getElementById("result").value="";
}
function show(input) {
document.getElementById("result").value+=input;
console.log("ans",document.getElementById("result").value);
}
function cal() {
var out=eval(document.getElementById("result").value);
document.getElementById("result").value=out;
console.log("res",document.getElementById("result").value);
}