Jump to content

Need help with JavaScript random quote generator

Jeroen1322

Hi guys!

 

I have this .js file for a quote generator that i used a while back but i miss the code to put in the HTML. I forgot how to print.

 

The code is (quotes are Dutch): 

var quote = new Array()quote[0] = 'Er ligt een enorme kracht in het werkelijk op me nemen van mijn leven zoals het is. - Maurice Knegtel'quote[1] = 'We leren op drie manieren: Begrijpen met verstand, ervaren met het hart en doen met het lichaam. - Satish Kumar'quote[2] = 'Je hoeft niet op elke gedachte die in je op komt in te gaan. - Michael A.Singer'quote[3] = 'Laat dingen gebeuren in plaats van dat jij dingen laat gebeuren. - Satish Kumar'quote[4] = 'Een emotie die zo groot als een huis aanvoelt kan steen voor steen afgebroken worden. - Sakyong Mipham'quote[5] = 'Veel pijn die we voelen komt voor uit onze reactie op pijn, veel onrust uit opwinding over onrus. - Tim Parks'quote[6] = 'Leraren zijn er alleen maar om het pad aan te wijzen; al het geploeter moet je zelf doen. - Noah Levine'var randomquote = Math.floor(Math.random()*(quote.length));function printquote(){document.write(quote[randomquote]);}

Soooo.. what i want is the code to put in the HTML because i can't figure it out. 

 

 

Thanks! :)

 

Edit: sorry i wan't really clear. What i want is that there will be displayed is a random quote from the .js file.

[CPU: AMD FX-6100 @3.3GHz ] [MoBo: Asrock 970 Extreme4] [GPU: Gigabyte 770 OC ] [RAM: 8GB] [sSD: 64gb for OS] [PSU: 550Watt Be Quiet!] [HDD: 1TB] [CPU cooler: Be Quiet! Shadow Rock Pro Sr1]  -Did i solve your question/problem? Please click 'Marked Solved'-

Link to comment
Share on other sites

Link to post
Share on other sites

Something like this: 

quoteText = document.createTextNode(quote[randomquote]);document.getElementById("quote-container").appendChild(quoteText);

will put the text in an html element with the id "quote-container"

I remain,  

msevilgenius

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×