Question

QUOTE OF THE DAY not totally working in JAVA I need to fix this code, the...

QUOTE OF THE DAY not totally working in JAVA

I need to fix this code, the problem that I have is that I have to include before the listed quotes , one of the quotes and the date and later are the listed quotes. Now when I run it , it only shows the title and the list of quotes. I have been trying to figure out the problem, any help...?

I need it to run

the title "Quote of the Day"

then a randon quote

then the date

and then the list of all the quotes, here is the code


JSJQ QUOTES and Date File

Quote of the Day

All the quotes:

this is what I have fo now...

<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8">
<title>QUOTE OF THE DAY AND DATE / Date Starter File</title>

<style>
    body{
        font-family: arial, sans-serif;
        font-size: 100%;
    }
    form{
        margin-top: 50px;
    }
</style>

<script>

    //************************************************************
    // 1: define variables for today's date,
    //************************************************************
    var today = new Date();
    var day = today.getDate();
    var month = today.getMonth();
    var year = today.getFullYear();

    //************************************************************
    // 2: define an array to hold the day names
    //************************************************************
    var monthArray = new Array();

    monthArray[0] = "January";
    monthArray[1] = "February";
    monthArray[2] = "March";
    monthArray[3] = "April";
    monthArray[4] = "May";
    monthArray[5] = "June";
    monthArray[6] = "July";
    monthArray[7] = "August";
    monthArray[8] = "September";
    monthArray[9] = "October";
    monthArray[10] = "November";
    monthArray[11] = "December";

    var dayArray = new Array();

    dayArray[0] = "Monday";
    dayArray[1] = "Tuesday";
    dayArray[2] = "Wednesday";
    dayArray[3] = "Thursday";
    dayArray[4] = "Friday";
    dayArray[5] = "Saturday";
    dayArray[6] = "Sunday";


    //************************************************************
    // 3: define an array to hold the daily quotes
    //************************************************************

    var quoteArray = new Array();

    quoteArray[0] = "Nothing is impossible, the word itself says 'I'm possible'!-Audrey Hepburn";
    quoteArray[1] = "The best preparation for tomorrow is doing your best today.-H. Jackson Brown, Jr";
    quoteArray[2] = "Try to be a rainbow in someone's cloud.-Maya Angelou";
    quoteArray[3] = "If opportunity doesn't knock, build a door.-Milton Berle";
    quoteArray[4] = "People won't have time for you if you are always angry or complaining.-Stephen Hawking";
    quoteArray[5] ="Realize deeply that the present moment is all you have. Make the ‘now’ the primary focus of your life.-Eckhart Tolle"
    quoteArray[6] = "When you judge another, you do not define them, you define yourself.-Wayne Dyer";
    quoteArray[7] = "Don’t wish it were easier. Wish you were better.-Jim Rohn";
    quoteArray[8] = "Just remember that Dumbo didn’t need the feather; the magic was in him.-Stephen King";
    quoteArray[9] = "Logic is the beginning of wisdom, not the end.- Mr.Spock Star Trek ";


    //************************************************************
    // 4: loop through all of the quotes
    //    and write the quotes to the page. Use DOM methods or innerHTML
    //    to write to the page.
    //************************************************************
    function allQuotes() {

        var allQuotes = document.getElementById('quotes');

        for (var i = 0; i < quoteArray.length; i++) {

            var text = document.createTextNode(quoteArray[i]);
            var br = document.createElement('br');

            allQuotes.appendChild(text);
            allQuotes.appendChild(br);
        }

        quoteOfTheDay();
    }

    //************************************************************
    // 5: create a window.onload function to format and display
    //    the current day name.
    //
    //    Display the quote for the day.
    //
    //   
    //************************************************************

    function quoteOfTheDay() {
        document.getElementById('quote_of_the_day').firstChild.nodeValue = quoteArray[today.getDay()-1];

        document.getElementById('date').firstChild.nodeValue = dayArray[day] + ", " + monthArray[month] + day + ", " + year;
    }

    window.onload = allQuotes;

</script>

</head>

<body>
<h1>Quote of the Day</h1>
<p id="quote_of_the_day"></p>
<p id="date"></p>

<h2>All the quotes:</h2>
<p id="quotes"></p>
</body>
</html>

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you need any clarification, please give me comment...

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>QUOTE OF THE DAY AND DATE / Date Starter File</title>

<style>

body {

font-family: arial, sans-serif;

font-size: 100%;

}

form {

margin-top: 50px;

}

</style>

<script>

//************************************************************

// 1: define variables for today's date,

//************************************************************

var today = new Date();

var day = today.getDate();

var month = today.getMonth();

var year = today.getFullYear();

//************************************************************

// 2: define an array to hold the day names

//************************************************************

var monthArray = new Array();

monthArray[0] = "January";

monthArray[1] = "February";

monthArray[2] = "March";

monthArray[3] = "April";

monthArray[4] = "May";

monthArray[5] = "June";

monthArray[6] = "July";

monthArray[7] = "August";

monthArray[8] = "September";

monthArray[9] = "October";

monthArray[10] = "November";

monthArray[11] = "December";

var dayArray = new Array();

dayArray[0] = "Monday";

dayArray[1] = "Tuesday";

dayArray[2] = "Wednesday";

dayArray[3] = "Thursday";

dayArray[4] = "Friday";

dayArray[5] = "Saturday";

dayArray[6] = "Sunday";

//************************************************************

// 3: define an array to hold the daily quotes

//************************************************************

var quoteArray = new Array();

quoteArray[0] = "Nothing is impossible, the word itself says 'I'm possible'!-Audrey Hepburn";

quoteArray[1] = "The best preparation for tomorrow is doing your best today.-H. Jackson Brown, Jr";

quoteArray[2] = "Try to be a rainbow in someone's cloud.-Maya Angelou";

quoteArray[3] = "If opportunity doesn't knock, build a door.-Milton Berle";

quoteArray[4] = "People won't have time for you if you are always angry or complaining.-Stephen Hawking";

quoteArray[5] = "Realize deeply that the present moment is all you have. Make the ‘now’ the primary focus of your life.-Eckhart Tolle"

quoteArray[6] = "When you judge another, you do not define them, you define yourself.-Wayne Dyer";

quoteArray[7] = "Don’t wish it were easier. Wish you were better.-Jim Rohn";

quoteArray[8] = "Just remember that Dumbo didn’t need the feather; the magic was in him.-Stephen King";

quoteArray[9] = "Logic is the beginning of wisdom, not the end.- Mr.Spock Star Trek ";

//************************************************************

// 4: loop through all of the quotes

// and write the quotes to the page. Use DOM methods or innerHTML

// to write to the page.

//************************************************************

function allQuotes() {

var allQuotes = document.getElementById('quotes');

for (var i = 0; i < quoteArray.length; i++) {

var text = document.createTextNode(quoteArray[i]);

var br = document.createElement('br');

allQuotes.appendChild(text);

allQuotes.appendChild(br);

}

quoteOfTheDay();

}

//************************************************************

// 5: create a window.onload function to format and display

// the current day name.

//

// Display the quote for the day.

//

//

//************************************************************

function quoteOfTheDay() {

var rand = Math.floor(Math.random() * quoteArray.length);

document.getElementById('quote_of_the_day').innerHTML = quoteArray[rand];

document.getElementById('date').innerHTML = dayArray[day] + ", " + monthArray[month] + " "+day + ", " + year;

}

window.onload = allQuotes;

</script>

</head>

<body>

<h1>Quote of the Day</h1>

<p id="quote_of_the_day"></p>

<p id="date"></p>

<h2>All the quotes:</h2>

<p id="quotes"></p>

</body>

</html>

Add a comment
Know the answer?
Add Answer to:
QUOTE OF THE DAY not totally working in JAVA I need to fix this code, the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This question relates to Javascript. Could you please show me why my code is not working?...

    This question relates to Javascript. Could you please show me why my code is not working? I want to create 2 text boxes and have the user enter something into both of them. If the text entered into both boxes is identical the a green message is made visible. If the boxes are different a red message is made visable. Please keep it simple because I am new to javascript. <html> <head>               <title></title>        <script>...

  • I am trying to create a slide show using JavaScript. This is what I have so...

    I am trying to create a slide show using JavaScript. This is what I have so far: HTML: <!DOCTYPE html> <html lang="en"> <head>    <meta charset="utf-8"> <title>Slide Show</title> <link rel="stylesheet" href="main.css"> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <script src="slide_show.js"></script> </head> <body> <section> <h1>Fishing Slide Show</h1> <ul id="image_list"> <li><a href="images/casting1.jpg" title="Casting on the Upper Kings"></a></li> <li><a href="images/casting2.jpg" title="Casting on the Lower Kings"></a></li> <li><a href="images/catchrelease.jpg" title="Catch and Release on the Big Horn"></a></li> <li><a href="images/fish.jpg" title="Catching on the South Fork"></a></li> <li><a href="images/lures.jpg" title="The Lures for Catching"></a></li> </ul>...

  • I have the code buts its not working as this below instruction can anyone help Use...

    I have the code buts its not working as this below instruction can anyone help Use the requirements from the pizza part of Assignment 6 and do the following using CSS and an internal style sheet: 1.     Your Javascript function should be in an external file (don’t forget to move it up to studentweb too) 2.     Put a red border of 300px in width around the form 3.     There should be three Div sections: header, main_body, and footer. 4.     Center the name of your...

  • I have some code for HTML/Javascript but I need to change it up a bit. Heres...

    I have some code for HTML/Javascript but I need to change it up a bit. Heres the assignment and what I have. The part in the bold is what I need help with. I need a button called new timer for when it reaches zero... Thank you. Assignment For this assignment, you will write a timer application in HTML and JavaScript. Your HTML document should contain the following elements/features: HTML tags: An <input> tag labeled "Timer Duration" with the initial...

  • For this discussion, you will be working with regular expressions. Please create a regular expression that...

    For this discussion, you will be working with regular expressions. Please create a regular expression that requires passwords to begin with an uppercase letter, followed by five lowercase letters, followed by a one-digit number (0-9), and ending with one symbol (@, $, %, or &). You may use the index.htm file included with this discussion to test your regular expression. Note that the index.htm file contains HTML and JavaScript. To test your regular expression, simply assign your regular expression to...

  • <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 4 Hands-on Project 4-3 Author: Da...

    <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 4 Hands-on Project 4-3 Author: Date:    Filename: index.htm --> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Hands-on Project 4-3</title> <link rel="stylesheet" href="styles.css" /> <script src="modernizr.custom.05819.js"></script> </head> <body> <header> <h1> Hands-on Project 4-3 </h1> </header> <article> <div id="results"> <p id="resultsExpl"></p> <ul> <li id="item1"></li> <li id="item2"></li> <li id="item3"></li> <li id="item4"></li> <li id="item5"></li> </ul> </div> <form> <fieldset> <label for="placeBox" id="placeLabel"> Type the name of a place, then click Submit: </label> <input type="text" id="placeBox"...

  • HTML Canvas: I have given my small html + js mix code below. By this program-...

    HTML Canvas: I have given my small html + js mix code below. By this program- I can just draw line, but after drawing any image I want to save the "image " on my desktop. I understand, I have to make a "button" to SAVE it and later if I want to load the picture, then I have to make a button on the webpage to "LOAD". But I am unable to understand the function I should write for...

  • Trying to understand java script.. The code provided prints out a game board of cells that...

    Trying to understand java script.. The code provided prints out a game board of cells that are 10 x 10.   I currnetly have it printed out so that it will print out pink squares. how can i create a click even on any of the pink squares that when they are clicked it will turn the square black...   then any square that is black when it is clicked it will change back to the color pink html/js code and css...

  • Please advise what is being doing wrong. Requirement. See if you can modify the code of...

    Please advise what is being doing wrong. Requirement. See if you can modify the code of Listings 17.1 and 17.3 to present a message to the user while waiting for an Ajax request to complete. //Code <!DOCTYPE html> <html> <head> <title>Keywords Grabber</title> <script src="myAjaxLib.js"></script> <script> function display(content) { document.getElementById("displaydiv").innerHTML = content; </script> <script> function getXMLHttpRequest() { try { try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { return new ActiveXObject("Msxml2.XMLHTTP"); } } catch(e) { return new XMLHttpRequest(); } } function doAjax(url,...

  • LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but,...

    LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but, I keep getting an error that I coded "Wrong username and password!" ***PLEASE DONT GIVE ME A NEW CODE THAT IS NOWHERE NEAR THE CODE I SUBMITTED***** PLEASE LOOK AT THE CODE AND SEE ANY ISSUES login.html <!DOCTYPE html> <html> <head> <title>login popup</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <style type="text/css"> body { background-color: white; } </style> </head> <body> <center> <h1 style="text-align: center;"> Login </h1> <form>             Login ID:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT