<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Quote generator</title> <link rel="stylesheet" href="css/styles.css"> </head> <body> <h1 class = "quotes">Quotes</h1> <img src ="https://placeimg.com/1100/300/nature" alt="nature" class="nature"> <div id = "output"> </div> <script type ="text/javascript" src="js/student_report.js"></script> <button onclick="print(blank)">Click me</button> </body> </html > Blockquote function print(message) { var output = document.getElementById('output'); output.innerHTML = message; }Blockquote
var blank = "";
function print(message) {
var output = document.getElementById('output');
output.innerHTML = message;
}
function getQuote(array) {
var quotes = '<h2 class="quote">' + 'quote: ' + array.quote + '</h2>';
quotes += '<p class="source">' + 'Soure: ' + array.source + '</p>';
quotes += '<p class="year">' + 'year: ' + array.year + '</p>';
quotes += '<p class="citation">' + 'citation: ' + array.citation + '</p>';
return quotes
};
>
var quotes = [{
quote: "Great man", source: "jack mike", year: 1990, citation: "movie"},
{ quote: "Good stuff", source:"Mac jones", year: 1989, citation: "book"},
{ quote: "i love you", source: "mom and dad", year: 1993, citation: "love"},
{quote: "you're a hero", source: "hero man", year: 2020, citation: "future"},
{quote: "you're a wizard", source: "hero wizard", year: 2022, citation: "future4"},
{quote: "you're a man", source: "hero man33", year: 2025, citation: "future3"},
{quote: "you're a good person", source: "hero person", year: 2021, citation: "future2"},
{quote: "you're a web developer", source: "hero developer", year: 2026, citation: "futures"}
];
var i = Math.round(Math.random() * quotes.length - 1);
blank += getQuote(quotes[i]);
print(blank);
function timer(){
setInterval(print(blank), 3000);
}
timer();
So here I need to link that print function to the onclick so that when I click the button, it keeps printing out that message to the page in the same spot. It's a random quote generator code so what I want is it prints random quotes to the page when i click the button.
When I load the page everything loads as it should, but when I click the button NOTHING happens, just clicks and that's it.
IGNORE THE QUOTES TEXT its stupid dumb stuff long story, i would never use those quotes for a actual website
Sorry if I gave a bad description, as you can see I'm new to coding.
Thank you for the help!