top of page
Search
Writer's picturelinuxtech

how to make a simple calculator using HTML.

Updated: Jun 19, 2020


<!DOCTYPE html>

<html>

<head>

<title>Calculator - Linux Tech</title>

</head>

<body>

<div id='calc-contain'>

<form name="calculator">

<input type="text" name="answer" />

<br>

<input type="button" value=" 1 " onclick="calculator.answer.value += '1'" />

<input type="button" value=" 2 " onclick="calculator.answer.value += '2'" />

<input type="button" value=" 3 " onclick="calculator.answer.value += '3'" />

<input type="button" value=" + " onclick="calculator.answer.value += '+'" />

<br/>

<input type="button" value=" 4 " onclick="calculator.answer.value += '4'" />

<input type="button" value=" 5 " onclick="calculator.answer.value += '5'" />

<input type="button" value=" 6 " onclick="calculator.answer.value += '6'" />

<input type="button" value=" - " onclick="calculator.answer.value += '-'" />

</br>

<input type="button" value=" 7 " onclick="calculator.answer.value += '7'" />

<input type="button" value=" 8 " onclick="calculator.answer.value += '8'" />

<input type="button" value=" 9 " onclick="calculator.answer.value += '9'" />

<input type="button" value=" x " onclick="calculator.answer.value += '*'" />

</br>

<input type="button" value=" c " onclick="calculator.answer.value = ''" />

<input type="button" value=" 0 " onclick="calculator.answer.value += '0'" />

<input type="button" value=" = " onclick="calculator.answer.value = eval(calculator.answer.value)" />

<input type="button" value=" / " onclick="calculator.answer.value += '/'" />

</br>

</form>

<div id="agh">

<p>linux tech's calculator

</div>

</div>

</body>

</html>


26 views0 comments

Recent Posts

See All

HOw to make a simple login form using HTML.

source code: <html> <head> <title>Login Page</title> </head> <body> <form name="loginForm" method="post" action="login.php"> <table...

How to make a simple snake game using html

source code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width,...

Comments


bottom of page