Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2014
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3.  
  4. <form onsubmit="triggerCalc()">
  5.  Username:<input type="text" id="userInput1" name="username"></input> <br>
  6.  Password:<input type="password" id="userInput2" name="password"></input>  <br>
  7. <br> Choose your genre: <br>
  8. <input type="radio" name="genre" value="male">Male<br>
  9. <input type="radio" name="genre" value="female">Female<br>
  10. <br>Country:
  11.  
  12. <select name="Country">
  13. <option value="Bulgaria">Bulgaria</option>
  14. <option value="United States">United States</option>
  15. </select> <br><br> I agree to the website's <a href="">license terms</a>
  16. <input type="checkbox" value="checkbox1"><br><br>
  17. <input type="submit" value="Continue..">
  18. </form>
  19.  
  20.  
  21. </head>
  22. <body background="sky_107.bmp">
  23. <script type="text/javascript">
  24.  
  25. var user = document.forms[0].username.value;
  26. var pw = document.forms[0].password.value;
  27.  
  28. function triggerCalc(){
  29.     if (pw.length < 5 && user.length < 3){
  30.         alert("An error occured");
  31.         }
  32.     else  {
  33.         alert("Thank you for registering to my website.");
  34.         var action = prompt("Welcome to my calculator. For addition press 1, for substraction press 2, for multiplication press 3, for division press 4 and for square root press 5:", "");
  35.  
  36.         var firstNum = new Array();
  37.         var secondNum = new Array();
  38.         var result = new Array();
  39.  
  40. switch (action) {
  41.     case "1":
  42.         firstNum[0] = prompt("You chose addition. Please enter a number:", "");
  43.         secondNum[0] = prompt("Now please enter another number", "");
  44.         result[0] = firstNum[0]*1 + secondNum[0]*1;
  45.         document.write("The result of the addition of " + firstNum[0] + " with " + secondNum[0] + " is: " + result[0]);
  46.             break;
  47.  
  48.     case "2":
  49.         firstNum[1] = prompt("You chose substraction. Please enter a number: ", "");
  50.         secondNum[1] = prompt("Now please enter another number: ", "");
  51.         result[1] = firstNum[1]*1 - secondNum[1]*1;
  52.         document.write("The result of the substraction of " +  firstNum[1] + " with " + secondNum[1] + " is: " + result[1]);
  53.             break;
  54.        
  55.     case "3":
  56.         firstNum[2]= prompt("You chose multiplication. Please enter a number: ", "");
  57.         secondNum[2] = prompt("Now enter another number:", "");
  58.         result[2] = firstNum[2]*1 * secondNum[2]*1;
  59.         document.write("The result of the multiplication of " + firstNum[2] + " with " + secondNum[2] + " is: " + result[2]);
  60.             break;
  61.        
  62.     case "4":
  63.         firstNum[3] = prompt("You chose divison. Please enter a number: ", "");
  64.         secondNum[3] = prompt ("Now enter another number: ", "");
  65.         result[3] = firstNum[3]*1 / secondNum[3]*1;
  66.         document.write("The result of the division of " + firstNum[3] + " with " + secondNum[3] + " is: " + result[3]);
  67.             break;
  68.        
  69.     case "5":
  70.         var inputNum = prompt("You chose square root. Please enter a number: ", "");
  71.         var rooted = Math.sqrt(inputNum);
  72.         document.write("The square root of: " + inputNum + " is: " + rooted);
  73.             break;
  74.     default:
  75.         document.write("You entered an invalid number. We will now show you our other features. Try again?");
  76.    
  77.     }
  78.         }
  79.  
  80. }
  81.  
  82.  
  83. </script>
  84. </body>
  85. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement