The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Help with displaying random text
belac77
post Jun 30 2012, 05:30 PM
Post #1





Group: Members
Posts: 2
Joined: 30-June 12
Member No.: 17,360



I found a html script for displaying random text online. I plan on using it to display random facts about a movie I run a fansite for. However, once I added more facts on, it wouldn't run correctly!
Here is the script, can someone please tell me what to add/take away/change to make it work?
Thanks, Caleb

HERE'S THE CODE:
<script language="JavaScript">
<!--
var r_text = new Array ();
r_text[0] = " The Coraline movie is the longest stop-motion film ever made.";
r_text[1] = " Henry Selick is the director of the Coraline movie.";
r_text[2] = " Coraline’s natural hair color is a medium-brown.";
r_text[3] = " The Coraline movie is set in Oregon.";
r_text[4] = " Coraline calls her yellow mud boots, “Swampers”.";
r_text[5] = " Wybie was created just for the Coraline movie. He does not appear in the book.";
r_text[6] = " The dogs talk in the book. They do not speak in the movie.";
r_text[7] = " The Other Mother is not dead and gone. She still lives!";
r_text[8] = " Subscribe to our blog by email for the latest Coraline news.";
r_text[9] = " The Coraline movie was originally intended to be a musical. All the songs were cut out in the end though, except for the Other Father song.";
r_text[10] = " In the Coraline movie, when Coraline wants the gloves in the store, they are a weird pattern of orange. In the book, however, they are day-glo green!";
r_text[11] = " Coraline has also been made into a stage musical, produced by MCC Theater in New York, with music and lyrics by Stephin Merritt of The Magnetic Fields. ";
r_text[12] = " Coraline is the first stop-motion animated feature to be shot entirely in 3-D.";
r_text[13] = " The red lighthouse visible in one of the snow globes Coraline places on the shelf was modeled after Big Red, the lighthouse at the Holland State park in Holland, Michigan.";
r_text[14] = " The original sweater the design team had designed for Coraline's father sported a big maize-and-blue University of Michigan logo. However producer Bill Mechanic decided to change the design in favor of his alma mater, Michigan State.";
r_text[15] = " The 'Ranft Bros. Moving Company' that moves Coraline's family into their home, are based on real-life brothers Jerome Ranft and Joe Ranft. Both brothers did work on The Nightmare Before Christmas with Director Henry Selick. The mover at the front door (who is given the $1.00 tip) is modeled after Joe Ranft.";
r_text[16] = " The "Detroit Zoo" snow globe featured in the film contains a model of The Horace Rackham Memorial Fountain, or the "Bear Fountain," sculpted by Corrado Parducci in 1939 as the centerpiece of the Detroit Zoo's reflecting pool.";
r_text[17] = " During a trapeze act in the 'Other World,' Ms Spink and Ms Forcible quote from Shakespeare's 'Hamlet'.The words they speak are part of a speech that Hamlet gives to a pair of courtiers.";
r_text[18] = " Mr. Bobinsky is wearing the Russian Hero Medal for Service at the Chernobyl Nuclear Disaster on April 26, 1986. Which reads on the front "Participant in the clean-up campaign" The "4A3C" indicates "Chernobilskaya Nuclear Power Plant." This medal is unique as it is the only medal in the world awarded for participation in a nuclear clean up. That might explain his skin complexion and odd behavior.";
r_text[19] = " The face on the dollar bill given to the mover for a tip is director, Henry Selick.";
r_text[20] = " The Coraline shoot lasted over 18 months, following 2 years of pre-production. ";
r_text[21] = " Over 130 sets were built across 52 different stages at the studios; spanning 183,000 square feet, the 52 different stages were the most ever deployed for a stop-motion animated feature.";
r_text[22] = " To construct 1 puppet of Coraline, 10 individuals had to work 3-4 months.";
r_text[23] = " For the character of Coraline, there were 28 different puppets of varying sizes; the main Coraline puppet stands 9.5 inches high.";
r_text[24] = " At one point in the movie, Coraline shows 16 different expressions in a span of 35 seconds. ";
r_text[25] = " Coraline's facial combinations consist of 3D printed prototypes. New technology enabled a prototype to be molded by a computer, which was then hand-painted by the modeling department. Each jaw replacement was clipped between Coraline's eyes, resulting in a visible line which was later digitally removed frame by frame. There were at total of 207,336 possible face combinations for the character. ";
r_text[26] = " This film marks the first time that a stop-motion animated morphing sequence has ever been accomplished. The sequence runs for 130 frames, or nearly six seconds.";
r_text[27] = " There are 248 Scottie Dogs in the audience with Coraline and Wybie watching the stage performance.";
r_text[28] = "1,300 square feet of fake fur was applied to stand in for live and/or dead grass.";
r_text[29] = " The on-screen snow was made from superglue and baking soda.";
r_text[30] = " The Pink Palace's address bears the same numbers as the nondescript warehouse where the film was produced. ";
r_text[31] = " On the back of the moving van you'll see graffiti on the bottom right corner that reads "StopMo Rulz." StopMo is short for Stop-Motion. ";
r_text[32] = " In a deleted portion of the table scene where Coraline's (real) father sings to her, he laments, "I think I have a virus." Coraline's father is voiced by John Hodgman, perhaps more famously known as "PC" in Apple's "I'm a Mac" advertisements, where he often complains of being susceptible to viruses.";

var i = Math.floor(7*Math.random())

document.write(r_text[i]);

(I've Left the Script tag out on purpose)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jun 30 2012, 08:22 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



I see some problems. Where you have quotes in your text strings you need to escape them with backslash, or JS will think the statement ends when it encounters the first quote and throw an error.
CODE
" The \"Detroit Zoo\" snow globe..."

Alternatively use single quotes when they belong to JS. I do both even if it isn't needed, i.e. use single quotes for JS and escape quotes in strings.

I also saw at least one occurrence of curly quotes from Word or a similar program. Replace them with ordinary quotes.

You need to change the Math.random statement to reflect the actual number of text snips you have now
See http://www.javascriptkit.com/javatutors/randomnum.shtml .
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
belac77
post Jul 14 2012, 03:33 PM
Post #3





Group: Members
Posts: 2
Joined: 30-June 12
Member No.: 17,360



QUOTE(pandy @ Jun 30 2012, 08:22 PM) *

I see some problems. Where you have quotes in your text strings you need to escape them with backslash, or JS will think the statement ends when it encounters the first quote and throw an error.
CODE
" The \"Detroit Zoo\" snow globe..."

Alternatively use single quotes when they belong to JS. I do both even if it isn't needed, i.e. use single quotes for JS and escape quotes in strings.

I also saw at least one occurrence of curly quotes from Word or a similar program. Replace them with ordinary quotes.

You need to change the Math.random statement to reflect the actual number of text snips you have now
See http://www.javascriptkit.com/javatutors/randomnum.shtml .


I tried these things, and it still didnt work! D:

Here is the code after i modified it:
<script language="JavaScript">
<!--
var r_text = new Array ();
r_text[0] = " The Coraline movie is the longest stop-motion film ever made.";
r_text[1] = " Henry Selick is the director of the Coraline movie.";
r_text[2] = " Coraline’s natural hair color is a medium-brown.";
r_text[3] = " The Coraline movie is set in Oregon.";
r_text[4] = " Coraline calls her yellow mud boots, Swampers.";
r_text[5] = " Wybie was created just for the Coraline movie. He does not appear in the book.";
r_text[6] = " The dogs talk in the book. They do not speak in the movie.";
r_text[7] = " The Other Mother is not dead and gone. She still lives!";
r_text[8] = " Subscribe to our blog by email for the latest Coraline news.";
r_text[9] = " The Coraline movie was originally intended to be a musical. All the songs were cut out in the end though, except for the Other Father song.";
r_text[10] = " In the Coraline movie, when Coraline wants the gloves in the store, they are a weird pattern of orange. In the book, however, they are day-glo green!";
r_text[11] = " Coraline has also been made into a stage musical, produced by MCC Theater in New York, with music and lyrics by Stephin Merritt of The Magnetic Fields. ";
r_text[12] = " Coraline is the first stop-motion animated feature to be shot entirely in 3-D.";
r_text[13] = " The red lighthouse visible in one of the snow globes Coraline places on the shelf was modeled after Big Red, the lighthouse at the Holland State park in Holland, Michigan.";
r_text[14] = " The original sweater the design team had designed for Coraline's father sported a big maize-and-blue University of Michigan logo. However producer Bill Mechanic decided to change the design in favor of his alma mater, Michigan State.";
r_text[15] = " The Ranft Bros. Moving Company that moves Coraline's family into their home, are based on real-life brothers Jerome Ranft and Joe Ranft. Both brothers did work on The Nightmare Before Christmas with Director Henry Selick. The mover at the front door (who is given the $1.00 tip) is modeled after Joe Ranft.";
r_text[16] = " The Detroit Zoo snow globe featured in the film contains a model of The Horace Rackham Memorial Fountain, or the "Bear Fountain," sculpted by Corrado Parducci in 1939 as the centerpiece of the Detroit Zoo's reflecting pool.";
r_text[17] = " During a trapeze act in the Other World, Ms Spink and Ms Forcible quote from Shakespeare's Hamlet.The words they speak are part of a speech that Hamlet gives to a pair of courtiers.";
r_text[18] = " Mr. Bobinsky is wearing the Russian Hero Medal for Service at the Chernobyl Nuclear Disaster on April 26, 1986. Which reads on the front Participant in the clean-up campaign. The 4A3C indicates Chernobilskaya Nuclear Power Plant. This medal is unique as it is the only medal in the world awarded for participation in a nuclear clean up. That might explain his skin complexion and odd behavior.";
r_text[19] = " The face on the dollar bill given to the mover for a tip is director, Henry Selick.";
r_text[20] = " The Coraline shoot lasted over 18 months, following 2 years of pre-production. ";
r_text[21] = " Over 130 sets were built across 52 different stages at the studios; spanning 183,000 square feet, the 52 different stages were the most ever deployed for a stop-motion animated feature.";
r_text[22] = " To construct 1 puppet of Coraline, 10 individuals had to work 3-4 months.";
r_text[23] = " For the character of Coraline, there were 28 different puppets of varying sizes; the main Coraline puppet stands 9.5 inches high.";
r_text[24] = " At one point in the movie, Coraline shows 16 different expressions in a span of 35 seconds. ";
r_text[25] = " Coraline's facial combinations consist of 3D printed prototypes. New technology enabled a prototype to be molded by a computer, which was then hand-painted by the modeling department. Each jaw replacement was clipped between Coraline's eyes, resulting in a visible line which was later digitally removed frame by frame. There were at total of 207,336 possible face combinations for the character. ";
r_text[26] = " This film marks the first time that a stop-motion animated morphing sequence has ever been accomplished. The sequence runs for 130 frames, or nearly six seconds.";
r_text[27] = " There are 248 Scottie Dogs in the audience with Coraline and Wybie watching the stage performance.";
r_text[28] = "1,300 square feet of fake fur was applied to stand in for live and/or dead grass.";
r_text[29] = " The on-screen snow was made from superglue and baking soda.";
r_text[30] = " The Pink Palaces address bears the same numbers as the nondescript warehouse where the film was produced. ";
r_text[31] = " On the back of the moving van you'll see graffiti on the bottom right corner that reads StopMo Rulz. StopMo is short for Stop-Motion. ";
r_text[32] = " In a deleted portion of the table scene where Coraline's (real) father sings to her, he laments, I think I have a virus. Coralines father is voiced by John Hodgman, perhaps more famously known as PC in Apple's I'm a Mac advertisements, where he often complains of being susceptible to viruses.";

var i = Math.floor(33*Math.random())

document.write(r_text[i]);

//-->
</script>

Whats wrong with it now?

(Thanks for commenting and trying to help me by the way)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 14 2012, 04:06 PM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



QUOTE(belac77 @ Jul 14 2012, 10:33 PM) *

I tried these things, and it still didnt work! D:


Nuh, you didn't. You removed the quotes in the strings instead, except you missed one occurrence. And that's why it doesn't work. wink.gif

CODE
r_text[16] = " The Detroit Zoo snow globe featured in the film contains a model of The Horace Rackham Memorial Fountain, or the "Bear Fountain," sculpted by Corrado Parducci in 1939 as the centerpiece of the Detroit Zoo's reflecting pool.";


Turn on script debugging in your browser(s). Most of them have that available. The debugger will tell you what errors you have, even if it can be a little cryptic, and where they are.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 18th March 2024 - 10:40 PM