We Recommend

HTML: The Definitive Guide HTML: The Definitive Guide
They teach you that learning HTML is like learning any other language and that reading a book of rules can only take you so far. Readers begin writing what may be their first Web page just two pages into the book's second chapter. From there on, they provide a wide range of HTML coding to allow readers to learn from good examples. The book includes a handy "cheat sheet" of HTML codes for quick reference.


Posted By

philapple on 11/19/06


Tagged

Calculator


Versions (?)


Calcolatrice


Published in: HTML 


URL: http://www.filippocorti.com/service/calcolatrice/

  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2.  
  3. <script language="JavaScript"
  4. type="text/javascript">
  5. //<![CDATA[
  6.  
  7. <!-- Eppol.net -->
  8.  
  9. <!-- Begin
  10. function doit() {
  11. form.input.value = eval(form.input.value)
  12. }
  13. function Cos() {
  14. x = form.input.value
  15. if (x == '') alert('Error: Input Required');
  16. else form.input.value = Math.cos(x);
  17. }
  18. function Sin() {
  19. x = form.input.value
  20. if (x == '') alert('Error: Input Required');
  21. else form.input.value = Math.sin(x);
  22. }
  23. function Ln() {
  24. x = form.input.value
  25. if (x == '') alert('Error: Input Required');
  26. else form.input.value = Math.log(x);
  27. }
  28. function Root() {
  29. x = form.input.value
  30. if (x == '') alert('Error: Input Required');
  31. else form.input.value = Math.sqrt(x);
  32. }
  33. function Tan() {
  34. x = form.input.value
  35. if (x == '') alert('Error: Input Required');
  36. else form.input.value = Math.tan(x);
  37. }
  38. function Icos() {
  39. x = form.input.value
  40. if (x == '') alert('Error: Input Required');
  41. else form.input.value = Math.acos(x);
  42. }
  43. function Isin() {
  44. x = form.input.value
  45. if (x == '') alert('Error: Input Required');
  46. else form.input.value = Math.asin(x);
  47. }
  48. function Itan() {
  49. x = form.input.value
  50. if (x == '') alert('Error: Input Required');
  51. else form.input.value = Math.atan(x);
  52. }
  53. function Round() {
  54. x = form.input.value
  55. if (x == '') alert('Error: Input Required');
  56. else form.input.value = Math.round(x);
  57. }
  58. function Ran() {
  59. x = form.input.value
  60. form.input.value = Math.random(x);
  61. }
  62. function Neg () {
  63. x = form.input.value
  64. if (x == '') alert('Error: Input Required');
  65. else x = parseFloat(x) * -1;
  66. }
  67. function del() {
  68. x = form.input.value
  69. x = (x.substring) - 1
  70. }
  71. // End -->
  72. //]]>
  73. </script>
  74.  
  75. <title></title>
  76. </head>
  77. <!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->
  78.  
  79. <body onload="document.form.input.focus()">
  80. <!-- STEP THREE: Copy this code into the BODY of your HTML document -->
  81.  
  82. <div align="center">
  83. <form name="form"
  84. method="post"
  85. action="javascript:doit()">
  86. <table width="260"
  87. border="0"
  88. height="260"
  89. align="center"
  90. bordercolor="#000000"
  91. bgcolor="#000000">
  92. <tr bgcolor="#000000">
  93. <td colspan="7"
  94. height="2">
  95. <div align="center">
  96. <b><font face="Arial, Helvetica, sans-serif"
  97. color="#FFFFFF">Advanced Scientific
  98. Calculator</font></b>
  99. </div>
  100.  
  101. </td>
  102. </tr>
  103.  
  104. <tr bgcolor="#000000">
  105. <td colspan="7"
  106. height="2">
  107. <div align="center">
  108. <input type="text"
  109. name="input"
  110. size="40" />
  111. </div>
  112. </td>
  113.  
  114. </tr>
  115.  
  116. <tr bgcolor="#000000">
  117. <td width="50"
  118. height="4"><input type="button"
  119. name="one"
  120. value="1"
  121. onclick="form.input.value += '1'"
  122. style=
  123. "COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px" /></td>
  124.  
  125. <td width="50"
  126. height="4"><input type="button"
  127. name="two"
  128. value="2"
  129. onclick="form.input.value += '2'"
  130. style=
  131. "COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px" /></td>
  132.  
  133. <td width="50"
  134. height="4"><input type="button"
  135. name="three"
  136. value="3"
  137. onclick="form.input.value += '3'"
  138. style=
  139. "COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px" /></td>
  140.  
  141. <td width="20"
  142. height="4">&nbsp;</td>
  143.  
  144. <td width="50"
  145. height="4"><input type="button"
  146. name="clear"
  147. value="C"
  148. onclick="form.input.value = ''"
  149. style=
  150. "COLOR: #FFFFFF; BACKGROUND-COLOR: #9F0004; HEIGHT: 25 px; WIDTH: 40px" /></td>
  151.  
  152. <td width="50"
  153. height="4"><input type="button"
  154. name="percent"
  155. value=" % "
  156. onclick=
  157. "form.input.value = eval(form.input.value) / 100"
  158. style=
  159. "COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  160.  
  161. <td width="50"
  162. height="4"><input type="button"
  163. name="("
  164. value=" ( "
  165. onclick="form.input.value += '('"
  166. style=
  167. "COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  168. </tr>
  169.  
  170. <tr bgcolor="#000000">
  171. <td width="50"
  172. height="2"><input type="button"
  173. name="four"
  174. value="4"
  175. onclick="form.input.value += '4'"
  176. style=
  177. "COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px" /></td>
  178.  
  179. <td width="50"
  180. height="2"><input type="button"
  181. name="five"
  182. value="5"
  183. onclick="form.input.value += '5'"
  184. style=
  185. "COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px" /></td>
  186.  
  187. <td width="50"
  188. height="2"><input type="button"
  189. name="six"
  190. value="6"
  191. onclick="form.input.value += '6'"
  192. style=
  193. "COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px" /></td>
  194.  
  195. <td width="20"
  196. height="2">&nbsp;</td>
  197.  
  198. <td width="50"
  199. height="2"><input type="button"
  200. name="times"
  201. value=" x "
  202. onclick="form.input.value += ' * '"
  203. style=
  204. "COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  205.  
  206. <td width="50"
  207. height="2"><input type="button"
  208. name="div"
  209. value=" / "
  210. onclick="form.input.value += ' / '"
  211. style=
  212. "COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  213.  
  214. <td width="50"
  215. height="2"><input type="button"
  216. name=")"
  217. value=" ) "
  218. onclick="form.input.value += ')'"
  219. style=
  220. "COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  221. </tr>
  222.  
  223. <tr bgcolor="#000000">
  224. <td width="50"
  225. height="2"><input type="button"
  226. name="seven"
  227. value="7"
  228. onclick="form.input.value += '7'"
  229. style=
  230. "COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px" /></td>
  231.  
  232. <td width="50"
  233. height="2"><input type="button"
  234. name="eight"
  235. value="8"
  236. onclick="form.input.value += '8'"
  237. style=
  238. "COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px" /></td>
  239.  
  240. <td width="50"
  241. height="2"><input type="button"
  242. name="nine"
  243. value="9"
  244. onclick="form.input.value += '9'"
  245. style=
  246. "COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px" /></td>
  247.  
  248. <td width="20"
  249. height="2">&nbsp;</td>
  250.  
  251. <td width="50"
  252. height="2"><input type="button"
  253. name="plus"
  254. value=" + "
  255. onclick="form.input.value += ' + '"
  256. style=
  257. "COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  258.  
  259. <td width="50"
  260. height="2"><input type="button"
  261. name="minus"
  262. value=" - "
  263. onclick="form.input.value += ' - '"
  264. style=
  265. "COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  266.  
  267. <td width="50"
  268. height="2"><input type="button"
  269. name="round"
  270. value="Rnd"
  271. onclick="Round()"
  272. style=
  273. "COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  274. </tr>
  275.  
  276. <tr bgcolor="#000000">
  277. <td width="50"
  278. height="2"><input type="button"
  279. name="zero"
  280. value="0"
  281. onclick="form.input.value += '0'"
  282. style=
  283. "COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px" /></td>
  284.  
  285. <td width="50"
  286. height="2"><input type="button"
  287. name="point"
  288. value="."
  289. onclick="form.input.value += '.'"
  290. style=
  291. "COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px" /></td>
  292.  
  293. <td width="50"
  294. height="2"><input type="button"
  295. name="pi"
  296. value="PI"
  297. onclick=
  298. "form.input.value += '3,1415926535897932384626433832795'"
  299. style=
  300. "COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px" /></td>
  301.  
  302. <td width="20"
  303. height="2">&nbsp;</td>
  304.  
  305. <td width="50"
  306. height="2"><input type="button"
  307. name="pi2"
  308. value="+/-"
  309. onclick="Neg()"
  310. style=
  311. "COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  312.  
  313. <td width="50"
  314. height="2"><input type="button"
  315. name="DoIt"
  316. value=" = "
  317. onclick="doit()"
  318. style=
  319. "COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  320.  
  321. <td width="50"
  322. height="2"><input type="button"
  323. name="round2"
  324. value="Ran#"
  325. onclick="Ran()"
  326. style=
  327. "COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  328. </tr>
  329.  
  330. <tr bgcolor="#000000">
  331. <td width="50"
  332. height="24">&nbsp;</td>
  333.  
  334. <td width="50"
  335. height="24">&nbsp;</td>
  336.  
  337. <td width="50"
  338. height="24">&nbsp;</td>
  339.  
  340. <td width="20"
  341. height="24">&nbsp;</td>
  342.  
  343. <td width="50"
  344. height="24">&nbsp;</td>
  345.  
  346. <td width="50"
  347. height="24">&nbsp;</td>
  348.  
  349. <td width="50"
  350. height="24">&nbsp;</td>
  351. </tr>
  352.  
  353. <tr bgcolor="#000000">
  354. <td width="50"><input type="button"
  355. name="quad"
  356. value="^2"
  357. onclick=
  358. "form.input.value = form.input.value * form.input.value"
  359. style=
  360. "COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px" /></td>
  361.  
  362. <td width="50"><input type="button"
  363. name="root"
  364. value="root"
  365. onclick="Root()"
  366. style=
  367. "COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px" /></td>
  368.  
  369. <td width="50"><input type="button"
  370. name="ln"
  371. value="ln"
  372. onclick="Ln()"
  373. style=
  374. "COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px" /></td>
  375.  
  376. <td width="20">&nbsp;</td>
  377.  
  378. <td width="50"><input type="button"
  379. name="1/2"
  380. value="1/2"
  381. onclick="form.input.value += '0.5'"
  382. style=
  383. "COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  384.  
  385. <td width="50"><input type="button"
  386. name="1/3"
  387. value="1/3"
  388. onclick="form.input.value += '0.3333333333'"
  389. style=
  390. "COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  391.  
  392. <td width="50"><input type="button"
  393. name="1/4"
  394. value="1/4"
  395. onclick="form.input.value += '0.25'"
  396. style=
  397. "COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  398. </tr>
  399.  
  400. <tr bgcolor="#000000">
  401.  
  402. <td width="50"><input type="button"
  403. name="sin"
  404. value="sin"
  405. onclick="Sin()"
  406. style=
  407. "COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px" /></td>
  408.  
  409. <td width="50"><input type="button"
  410. name="cos"
  411. value="cos"
  412. onclick="Cos()"
  413. style=
  414. "COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px" /></td>
  415.  
  416. <td width="50"><input type="button"
  417. name="tan"
  418. value="tan"
  419. onclick="Tan()"
  420. style=
  421. "COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px" /></td>
  422.  
  423. <td width="20">&nbsp;</td>
  424.  
  425. <td width="50"><input type="button"
  426. name="1/5"
  427. value="1/5"
  428. onclick="form.input.value += '0.2'"
  429. style=
  430. "COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  431.  
  432. <td width="50"><input type="button"
  433. name="1/6"
  434. value="1/6"
  435. onclick="form.input.value += '0.1666666667'"
  436. style=
  437. "COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  438.  
  439. <td width="50"><input type="button"
  440. name="1/7"
  441. value="1/7"
  442. onclick="form.input.value += '0.1428571429'"
  443. style=
  444. "COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  445. </tr>
  446.  
  447. <tr bgcolor="#000000">
  448. <td width="50"><input type="button"
  449. name="sin2"
  450. value="asin"
  451. onclick="Isin()"
  452. style=
  453. "COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px" /></td>
  454.  
  455. <td width="50"><input type="button"
  456. name="cos2"
  457. value="acos"
  458. onclick="Icos()"
  459. style=
  460. "COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px" /></td>
  461.  
  462. <td width="50"><input type="button"
  463. name="tan2"
  464. value="atan"
  465. onclick="Itan()"
  466. style=
  467. "COLOR: #FFFFFF; BACKGROUND-COLOR: #333333; HEIGHT: 25 px; WIDTH: 40px" /></td>
  468.  
  469. <td width="20">&nbsp;</td>
  470.  
  471. <td width="50"><input type="button"
  472. name="1/8"
  473. value="1/8"
  474. onclick="form.input.value += '0.125'"
  475. style=
  476. "COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  477.  
  478. <td width="50"><input type="button"
  479. name="1/9"
  480. value="1/9"
  481. onclick="form.input.value += '0.1111111111'"
  482. style=
  483. "COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  484.  
  485. <td width="50"><input type="button"
  486. name="1/10"
  487. value="1/10"
  488. onclick="form.input.value += '0.1'"
  489. style=
  490. "COLOR: #B3B300; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px" /></td>
  491. </tr>
  492. </table>
  493. </form>
  494.  
  495. </div>
  496.  
  497. <font face="arial, helvetica">F.C. Calcolatrice
  498. <br />
  499. by <a href="http://www.filippocorti.com">F.C.</a></font>
  500. </center>
  501.  
  502. <p><!-- Script Size: 13.44 KB --></p>
  503.  
  504. </body>
  505. </html>

Report this snippet 

You need to login to post a comment.