Advertisement
Guest User

Untitled

a guest
Sep 4th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. <!doctype html>
  2. <head>
  3. <h1>Exercise 3-1</h1>
  4. <script src ="X_3_1.js"></script>
  5. </head>
  6. <body>
  7. <p>Enter First Name:
  8. <input type="text" id="firstName">
  9. <br>
  10. Do you have children?:
  11. <input type="text" id="children">
  12. <br>
  13. If so, how old is your oldest child?:
  14. <input type="text" id="oldestChild">
  15. <br>
  16. <input type="button" onclick="processInfo()" value="Submit Information">
  17. <br>
  18. <span id="mymsg">*</span>
  19. </p>
  20. </body>
  21. </html>
  22.  
  23. function processInfo()
  24. {
  25. var firstName = document.getElementById("firstName").value;
  26. var children = document.getElementById("children").value;
  27. var oldestChild = document.getElementById("oldestChild").value;
  28. var childrenLower = children.toLowerCase();
  29. var today = new Date ();
  30.  
  31. if(childrenLower == "yes" || childrenLower == "y")
  32. {
  33. if(isNaN(oldestChild)){
  34. mymsg.firstChild.nodeValue = oldestChild + " is not a number";
  35. } else if(oldestChild <= 19){
  36. mymsg.firstChild.nodeValue = "You still have kids at home";
  37. } else if(oldestChild >= 19){
  38. mymsg.firstChild.nodeValue = "Hopefully they have moved out of the
  39. house";
  40. }
  41. } else if(childrenLower != "yes" || childrenLower != "y") {
  42. mymsg.firstChild.nodeValue = "It must be peacefule at home, " +
  43. firstName + "on this date of " today;
  44. }
  45. }
  46.  
  47. mymsg.firstChild.nodeValue = "Hopefully they have moved out of the
  48. house";
  49.  
  50. function processInfo() {
  51.  
  52. var firstName = document.getElementById("firstName").value;
  53. var children = document.getElementById("children").value;
  54. var oldestChild = parseInt(document.getElementById("oldestChild").value);
  55. var childrenLower = children.toLowerCase();
  56. var today = new Date();
  57. var mymsg=document.getElementById('mymsg');
  58.  
  59. if(childrenLower == "yes" || childrenLower == "y") {
  60.  
  61.  
  62.  
  63. if(isNaN(oldestChild)){
  64. mymsg.firstChild.nodeValue = oldestChild + " is not a number";
  65. }
  66.  
  67. else if(oldestChild <= 19){
  68. mymsg.firstChild.nodeValue = "You still have kids at home";
  69. }
  70.  
  71. else if(oldestChild >= 19){
  72. mymsg.firstChild.nodeValue = "Hopefully they have moved out of the house";
  73. }
  74.  
  75. } else if(childrenLower != "yes" || childrenLower != "y") {
  76. mymsg.firstChild.nodeValue = "It must be peacefule at home, " +
  77. firstName + "on this date of "+ today;
  78. }
  79.  
  80.  
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement