CALCULATOR | Skillshare Projects

Ashutosh K Singh

Just your friendly neighborhood Coder..

214

2

CALCULATOR

<html>
<head> <script >

function insert(num) { document.form.textview.value = document.form.textview.value + num;}
function eual() { document.form.textview.value = eval(document.form.textview.value);}
function clea() { document.form.textview.value = null;}
function back() { let x = document.form.textview.value; document.form.textview.value = x.substring(0, x.length - 1);}

</script> <script src="num.js">
</script> <style> *{ margin:0; padding:0; } .button{ width:50; height: 50; font-size: 25; margin: 2; cursor: pointer; border: none; background: grey; } .textview{ width: 223; margin:5; padding:5; font-size: 25; color:black; }.main{ position: absolute; top:50%; left:50%; transform:translateX(-50%)translateY(-50%);} </style></head>
<body id="hello"> <script language="javascript" src="10printchar.js" text="text/javscript"> </script> <div class="main"> <form name="form"> <input id="textview" class="textview"> </form> <table> <tr> <td><input class="button" type="button" value="C" onclick="clea()"> <td><input class="button" type="button" value="D" onclick="back()"> <td><input type="button" class="button" value='*' onclick="insert('*')"> <td><input class="button" type="button" value='/' onclick="insert('/')"> </tr>
<tr> <td><input type="button" class="button" value="7" onclick="insert(7)"></td> <td><input type="button" class="button" value="8" onclick="insert(8)"></td> <td><input type="button" class="button" value="9" onclick="insert(9)"></td> <td><input type="button" class="button" value='-' onclick="insert('-')"></td> </tr>
<tr> <td><input class="button" type="button" value="4" onclick="insert(4)"> <td><input type="button" class="button" value="5" onclick="insert(5)"> <td><input type="button" class="button" value="6" onclick="insert(6)"> <td><input type="button" class="button" value="+" onclick="insert('+')"> </tr>
<tr> <td><input type="button" class="button" value="1" onclick="insert(1)"> <td><input type="button" class="button" value="2" onclick="insert(2)"> <td><input type="button" class="button" value="3" onclick="insert(3)"> <td rowspan="2"><input type="button" style=height:100 class="button" value="=" onclick="eual()"> </tr>
<tr> <td colspan="2"><input type="button" style=width:100 class="button" value="0" onclick="insert(0)"> <td colspan><input type="button" class="button" value="." onclick="insert('.')"> </tr> </table>
</div>


</p></body>

</html>

Comments

Please sign in or sign up to comment.