Guest User

Untitled

a guest
Jul 23rd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <html>
  2. <title>
  3. Assignment 3
  4. </title>
  5. <head>
  6. <script type = "text/javascript">
  7. //java script goes here
  8.  
  9. // user-->
  10.  
  11. function calculate()
  12. {
  13. //initialize variable to hold the numbers and also parse the string to Ints!!
  14. var num1 =parseInt(document.getElementById("num1").value);
  15. var num2 = parseInt(document.getElementById("num2").value);
  16. var num3 = parseInt(document.getElementById("num3").value);
  17.  
  18. //calculate the numbers
  19. var newN2=(num1 *3);
  20. var newN3 =Math.pow(num1,3);
  21.  
  22. //update the form onthe fly
  23. document.getElementById("Nnum2").value = newN2;
  24. document.getElementById("Nnum3").value = newN3;
  25. }
  26.  
  27. </script>
  28. </head>
  29. <body>
  30.  
  31. <!--diplay a welcome message to the page !-->
  32. <h1 align ='center'><b>Assignment 2</b></h1>
  33. <!-- start the form -->
  34. <table align = "center" cellpadding = '5' cellspacing = '10'>
  35. <form name = 'form1' method = 'POST' />
  36. <tr >
  37. <td >
  38. Enter First Number:
  39. </td>
  40. <td><input size = '10' type ='text' id = "num1" keydown = "calculate();"/>
  41. </td>
  42. </tr>
  43. <tr>
  44. <td>
  45. Enter Second Number:
  46. </td>
  47. <td>
  48. <input type ='text' id = "num2" size = '10' keydown= "calculate();"/>
  49. </td>
  50. <!--Calculated Number -->
  51. <td>
  52. Calculated Number:
  53. </td>
  54. <td>
  55. <input type ='text' id = "Nnum2" size = '10' keydown = "calculate();"/>
  56. </td>
  57.  
  58. </tr>
  59. <tr>
  60. <td>
  61. Enter Third Number:
  62. </td>
  63. <td>
  64. <input type ='text' id = "num3" size = '10' keydown = "calculate();"/>
  65. </td>
  66.  
  67. <!--Calculated numbers :-->
  68.  
  69. <td>
  70. Calculated Number:
  71. </td>
  72. <td>
  73. <input size = '10'type ='text' id = "Nnum3" keydown = "calculate();"/>
  74. </td>
  75. </tr>
  76. <tr>
  77. <td align = 'center'>
  78. <input type = 'submit' id = 'submit' value = 'Calculate'/>
  79. </td>
  80. </tr>
  81. </form>
  82. </table>
  83. </body>
  84. </html>
Add Comment
Please, Sign In to add comment