Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <form onsubmit="triggerCalc()">
- Username:<input type="text" id="userInput1" name="username"></input> <br>
- Password:<input type="password" id="userInput2" name="password"></input> <br>
- <br> Choose your genre: <br>
- <input type="radio" name="genre" value="male">Male<br>
- <input type="radio" name="genre" value="female">Female<br>
- <br>Country:
- <select name="Country">
- <option value="Bulgaria">Bulgaria</option>
- <option value="United States">United States</option>
- </select> <br><br> I agree to the website's <a href="">license terms</a>
- <input type="checkbox" value="checkbox1"><br><br>
- <input type="submit" value="Continue..">
- </form>
- </head>
- <body background="sky_107.bmp">
- <script type="text/javascript">
- var user = document.forms[0].username.value;
- var pw = document.forms[0].password.value;
- function triggerCalc(){
- if (pw.length < 5 && user.length < 3){
- alert("An error occured");
- }
- else {
- alert("Thank you for registering to my website.");
- 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:", "");
- var firstNum = new Array();
- var secondNum = new Array();
- var result = new Array();
- switch (action) {
- case "1":
- firstNum[0] = prompt("You chose addition. Please enter a number:", "");
- secondNum[0] = prompt("Now please enter another number", "");
- result[0] = firstNum[0]*1 + secondNum[0]*1;
- document.write("The result of the addition of " + firstNum[0] + " with " + secondNum[0] + " is: " + result[0]);
- break;
- case "2":
- firstNum[1] = prompt("You chose substraction. Please enter a number: ", "");
- secondNum[1] = prompt("Now please enter another number: ", "");
- result[1] = firstNum[1]*1 - secondNum[1]*1;
- document.write("The result of the substraction of " + firstNum[1] + " with " + secondNum[1] + " is: " + result[1]);
- break;
- case "3":
- firstNum[2]= prompt("You chose multiplication. Please enter a number: ", "");
- secondNum[2] = prompt("Now enter another number:", "");
- result[2] = firstNum[2]*1 * secondNum[2]*1;
- document.write("The result of the multiplication of " + firstNum[2] + " with " + secondNum[2] + " is: " + result[2]);
- break;
- case "4":
- firstNum[3] = prompt("You chose divison. Please enter a number: ", "");
- secondNum[3] = prompt ("Now enter another number: ", "");
- result[3] = firstNum[3]*1 / secondNum[3]*1;
- document.write("The result of the division of " + firstNum[3] + " with " + secondNum[3] + " is: " + result[3]);
- break;
- case "5":
- var inputNum = prompt("You chose square root. Please enter a number: ", "");
- var rooted = Math.sqrt(inputNum);
- document.write("The square root of: " + inputNum + " is: " + rooted);
- break;
- default:
- document.write("You entered an invalid number. We will now show you our other features. Try again?");
- }
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement