Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <title>
- Assignment 3
- </title>
- <head>
- <script type = "text/javascript">
- //java script goes here
- // user-->
- function calculate()
- {
- //initialize variable to hold the numbers and also parse the string to Ints!!
- var num1 =parseInt(document.getElementById("num1").value);
- var num2 = parseInt(document.getElementById("num2").value);
- var num3 = parseInt(document.getElementById("num3").value);
- //calculate the numbers
- var newN2=(num1 *3);
- var newN3 =Math.pow(num1,3);
- //update the form onthe fly
- document.getElementById("Nnum2").value = newN2;
- document.getElementById("Nnum3").value = newN3;
- }
- </script>
- </head>
- <body>
- <!--diplay a welcome message to the page !-->
- <h1 align ='center'><b>Assignment 2</b></h1>
- <!-- start the form -->
- <table align = "center" cellpadding = '5' cellspacing = '10'>
- <form name = 'form1' method = 'POST' />
- <tr >
- <td >
- Enter First Number:
- </td>
- <td><input size = '10' type ='text' id = "num1" keydown = "calculate();"/>
- </td>
- </tr>
- <tr>
- <td>
- Enter Second Number:
- </td>
- <td>
- <input type ='text' id = "num2" size = '10' keydown= "calculate();"/>
- </td>
- <!--Calculated Number -->
- <td>
- Calculated Number:
- </td>
- <td>
- <input type ='text' id = "Nnum2" size = '10' keydown = "calculate();"/>
- </td>
- </tr>
- <tr>
- <td>
- Enter Third Number:
- </td>
- <td>
- <input type ='text' id = "num3" size = '10' keydown = "calculate();"/>
- </td>
- <!--Calculated numbers :-->
- <td>
- Calculated Number:
- </td>
- <td>
- <input size = '10'type ='text' id = "Nnum3" keydown = "calculate();"/>
- </td>
- </tr>
- <tr>
- <td align = 'center'>
- <input type = 'submit' id = 'submit' value = 'Calculate'/>
- </td>
- </tr>
- </form>
- </table>
- </body>
- </html>
Add Comment
Please, Sign In to add comment