Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <head>
- <h1>Exercise 3-1</h1>
- <script src ="X_3_1.js"></script>
- </head>
- <body>
- <p>Enter First Name:
- <input type="text" id="firstName">
- <br>
- Do you have children?:
- <input type="text" id="children">
- <br>
- If so, how old is your oldest child?:
- <input type="text" id="oldestChild">
- <br>
- <input type="button" onclick="processInfo()" value="Submit Information">
- <br>
- <span id="mymsg">*</span>
- </p>
- </body>
- </html>
- function processInfo()
- {
- var firstName = document.getElementById("firstName").value;
- var children = document.getElementById("children").value;
- var oldestChild = document.getElementById("oldestChild").value;
- var childrenLower = children.toLowerCase();
- var today = new Date ();
- if(childrenLower == "yes" || childrenLower == "y")
- {
- if(isNaN(oldestChild)){
- mymsg.firstChild.nodeValue = oldestChild + " is not a number";
- } else if(oldestChild <= 19){
- mymsg.firstChild.nodeValue = "You still have kids at home";
- } else if(oldestChild >= 19){
- mymsg.firstChild.nodeValue = "Hopefully they have moved out of the
- house";
- }
- } else if(childrenLower != "yes" || childrenLower != "y") {
- mymsg.firstChild.nodeValue = "It must be peacefule at home, " +
- firstName + "on this date of " today;
- }
- }
- mymsg.firstChild.nodeValue = "Hopefully they have moved out of the
- house";
- function processInfo() {
- var firstName = document.getElementById("firstName").value;
- var children = document.getElementById("children").value;
- var oldestChild = parseInt(document.getElementById("oldestChild").value);
- var childrenLower = children.toLowerCase();
- var today = new Date();
- var mymsg=document.getElementById('mymsg');
- if(childrenLower == "yes" || childrenLower == "y") {
- if(isNaN(oldestChild)){
- mymsg.firstChild.nodeValue = oldestChild + " is not a number";
- }
- else if(oldestChild <= 19){
- mymsg.firstChild.nodeValue = "You still have kids at home";
- }
- else if(oldestChild >= 19){
- mymsg.firstChild.nodeValue = "Hopefully they have moved out of the house";
- }
- } else if(childrenLower != "yes" || childrenLower != "y") {
- mymsg.firstChild.nodeValue = "It must be peacefule at home, " +
- firstName + "on this date of "+ today;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement