Among all the examples out there, you probably know that calculator examples always make an appearance.
Why is that?
You have each digit and a way to give it a defined command.
In other words, if each of the digits 0~9 becomes a function and the symbols +-/*% mix those functions together..
you can derive very diverse results..you should be able to pull it off..
Anyway,
let's warm up first before building the calculator..
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko"> |
|
|
|
|
|
<head> |
|
|
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> |
|
|
<title>Window Object Events & Event Handlers 3</title> |
|
|
|
|
|
<meta name="Keywords" content="" /> |
|
|
<meta name="Description" content="" /> |
|
|
|
|
|
<script type="text/javascript"> |
|
|
//<![CDATA[ |
|
|
|
|
|
function call(form){ |
|
|
form.cal.value = eval(form.cal.value); // string to number |
|
|
return false; // if true, it redirects to naver. |
|
|
} |
|
|
|
|
|
//]]]]]]> |
|
|
</script> |
|
|
</head> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<body> |
|
|
|
|
|
<form action="http://www.naver.com" onsubmit="return call(this);" > |
|
|
<input type="text" name="cal" value="20+30" /> <br /> |
|
|
<input type="submit" name="btn" value="Result" /> |
|
|
</form> |
|
|
|
|
|
</body> |
|
|
|
|
|
</html> |
