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

Report this snippet  

You need to login to post a comment.