Im trying to build the UK Grifball wiki with the help from a few other users. We are trying to make a random comment generator. We have this so far but it doesn't work:
{// create array of Grifball factsvar ar = new Array(20) ar[0] = "If all else fails blame Stranglers connection" ar[1] = "Ryan can't stiff arm" ar[2] = "GBGB are the only UK team to win their division with a perfect record" ar[3] = "Sexy Action Newsteam is my favorite team name ever" ar[4] = "Hellfire has the the highest kill count in the UK with 1579 (to date)" ar[5] = "The Shak attack is not a real move" ar[6] = "Hellfire has the highest betrayl count in the UK with 67 (to date)" ar[7] = "Definition of a Carkito- Failing with style" ar[8] = "Grifball is fun" ar[9] = "Drink 4 litres of Sunny D a day to become a real life bomb carrier" ar[10] = "Chief- 'EXIT!!! What are you doing you stupid pillock that's our goal'" ar[11] = "Muffin- 'I can give you what you want!'" ar[12] = "Can anyone tell me why no-one leaves SA anymore?" ar[13] = "I'm still pushing for The Fumblethingy to be formed" ar[14] = "Secretryan28 leads in bomb scores in the UK with 113 (to date)" ar[15] = "Does the term 'bonking' come from Scouts in TF2?" ar[16] = "UK Grifball- Served with tea and crumpets" ar[17] = "UK Grifball- We've got this or croquet" ar[18] = "UK Grifball- The best thing sinec the cork pipe" ar[19] = "Wales is the best Grifballing nation" var now = new Date()var sec = now.getSeconds()document.random.random.value="Here's somthing for ya: " + ar[sec % 20]}getMessage() //--> </SCRIPT> </Body> </HTML>
{// create array of Grifball factsvar ar = new Array(20)
- This isn't right it should be something like this
// create array of Grifball facts var ar = new array(20);
ar[0] = "If all else fails blame Stranglers connection"; ar[1] = "Ryan can't stiff arm"; ar[2] = "GBGB are the only UK team to win their division with a perfect record"; ar[3] = "Sexy Action Newsteam is my favorite team name ever"; ar[4] = "Hellfire has the the highest kill count in the UK with 1579 (to date)"; ar[5] = "The Shak attack is not a real move"; ar[6] = "Hellfire has the highest betrayl count in the UK with 67 (to date)"; ar[7] = "Definition of a Carkito- Failing with style"; ar[8] = "Grifball is fun"; ar[9] = "Drink 4 litres of Sunny D a day to become a real life bomb carrier"; ar[10] = "Chief- 'EXIT!!! What are you doing you stupid pillock that's our goal'"; ar[11] = "Muffin- 'I can give you what you want!'"; ar[12] = "Can anyone tell me why no-one leaves SA anymore?"; ar[13] = "I'm still pushing for The Fumblethingy to be formed"; ar[14] = "Secretryan28 leads in bomb scores in the UK with 113 (to date)"; ar[15] = "Does the term 'bonking' come from Scouts in TF2?"; ar[16] = "UK Grifball- Served with tea and crumpets"; ar[17] = "UK Grifball- We've got this or croquet"; ar[18] = "UK Grifball- The best thing sinec the cork pipe"; ar[19] = "Wales is the best Grifballing nation";
<SCRIPT LANGUAGE="JavaScript"> function getMessage(){ // create array of Grifball facts var ar = new array(20);
ar[0] = "If all else fails blame Stranglers connection"; ar[1] = "Ryan can't stiff arm"; ar[2] = "GBGB are the only UK team to win their division with a perfect record"; ar[3] = "Sexy Action Newsteam is my favorite team name ever"; ar[4] = "Hellfire has the the highest kill count in the UK with 1579 (to date)"; ar[5] = "The Shak attack is not a real move"; ar[6] = "Hellfire has the highest betrayl count in the UK with 67 (to date)"; ar[7] = "Definition of a Carkito- Failing with style"; ar[8] = "Grifball is fun"; ar[9] = "Drink 4 litres of Sunny D a day to become a real life bomb carrier"; ar[10] = "Chief- 'EXIT!!! What are you doing you stupid pillock that's our goal'"; ar[11] = "Muffin- 'I can give you what you want!'"; ar[12] = "Can anyone tell me why no-one leaves SA anymore?"; ar[13] = "I'm still pushing for The Fumblethingy to be formed"; ar[14] = "Secretryan28 leads in bomb scores in the UK with 113 (to date)"; ar[15] = "Does the term 'bonking' come from Scouts in TF2?"; ar[16] = "UK Grifball- Served with tea and crumpets"; ar[17] = "UK Grifball- We've got this or croquet"; ar[18] = "UK Grifball- The best thing sinec the cork pipe"; ar[19] = "Wales is the best Grifballing nation";
var now = new Date(); var sec = now.getSeconds(); document.random.value="Here's somthing for ya: " + ar[sec % 20]; } getMessage(); </SCRIPT> </Body> </HTML>
So close. Array is capitalised and the call to document.random.value should just be to random.value. You can also strip out the form and input names, leaving just the id. Might want to edit it on the full page but works sandboxed.
// create array of Grifball facts var ar = new Array(20);
ar[0] = "If all else fails blame Stranglers connection"; ar[1] = "Ryan can't stiff arm"; ar[2] = "GBGB are the only UK team to win their division with a perfect record"; ar[3] = "Sexy Action Newsteam is my favorite team name ever"; ar[4] = "Hellfire has the the highest kill count in the UK with 1579 (to date)"; ar[5] = "The Shak attack is not a real move"; ar[6] = "Hellfire has the highest betrayl count in the UK with 67 (to date)"; ar[7] = "Definition of a Carkito- Failing with style"; ar[8] = "Grifball is fun"; ar[9] = "Drink 4 litres of Sunny D a day to become a real life bomb carrier"; ar[10] = "Chief- 'EXIT!!! What are you doing you stupid pillock that's our goal'"; ar[11] = "Muffin- 'I can give you what you want!'"; ar[12] = "Can anyone tell me why no-one leaves SA anymore?"; ar[13] = "I'm still pushing for The Fumblethingy to be formed"; ar[14] = "Secretryan28 leads in bomb scores in the UK with 113 (to date)"; ar[15] = "Does the term 'bonking' come from Scouts in TF2?"; ar[16] = "UK Grifball- Served with tea and crumpets"; ar[17] = "UK Grifball- We've got this or croquet"; ar[18] = "UK Grifball- The best thing sinec the cork pipe"; ar[19] = "Wales is the best Grifballing nation";
function getMessage(){ var now = new Date(); var sec = now.getSeconds(); random.value="Here's somthing for ya: " + ar[sec % 20]; } getMessage(); </SCRIPT> </Body> </HTML>
EDIT - moved the array outside the function so that you don't rebuild it if you call the function again, if you choose to change the text later.
// create array of Grifball facts var ar = new Array(20);
ar[0] = "If all else fails blame Stranglers connection"; ar[1] = "Ryan can't stiff arm"; ar[2] = "GBGB are the only UK team to win their division with a perfect record"; ar[3] = "Sexy Action Newsteam is my favorite team name ever"; ar[4] = "Hellfire has the the highest kill count in the UK with 1579 (to date)"; ar[5] = "The Shak attack is not a real move"; ar[6] = "Hellfire has the highest betrayl count in the UK with 67 (to date)"; ar[7] = "Definition of a Carkito- Failing with style"; ar[8] = "Grifball is fun"; ar[9] = "Drink 4 litres of Sunny D a day to become a real life bomb carrier"; ar[10] = "Chief- 'EXIT!!! What are you doing you stupid pillock that's our goal'"; ar[11] = "Muffin- 'I can give you what you want!'"; ar[12] = "Can anyone tell me why no-one leaves SA anymore?"; ar[13] = "I'm still pushing for The Fumblethingy to be formed"; ar[14] = "Secretryan28 leads in bomb scores in the UK with 113 (to date)"; ar[15] = "Does the term 'bonking' come from Scouts in TF2?"; ar[16] = "UK Grifball- Served with tea and crumpets"; ar[17] = "UK Grifball- We've got this or croquet"; ar[18] = "UK Grifball- The best thing sinec the cork pipe"; ar[19] = "Wales is the best Grifballing nation";
function getMessage(){ var now = new Date(); var sec = now.getSeconds(); document.write("Here's somthing for ya: " + ar[sec % 20]) } getMessage(); </SCRIPT> </Body> </HTML>
// create array of Grifball facts var ar = new Array(20);
ar[0] = "If all else fails blame Stranglers connection"; ar[1] = "Ryan can't stiff arm"; ar[2] = "GBGB are the only UK team to win their division with a perfect record"; ar[3] = "Sexy Action Newsteam is my favorite team name ever"; ar[4] = "Hellfire has the the highest kill count in the UK with 1579 (to date)"; ar[5] = "The Shak attack is not a real move"; ar[6] = "Hellfire has the highest betrayl count in the UK with 67 (to date)"; ar[7] = "Definition of a Carkito- Failing with style"; ar[8] = "Grifball is fun"; ar[9] = "Drink 4 litres of Sunny D a day to become a real life bomb carrier"; ar[10] = "Chief- 'EXIT!!! What are you doing you stupid pillock that's our goal'"; ar[11] = "Muffin- 'I can give you what you want!'"; ar[12] = "Can anyone tell me why no-one leaves SA anymore?"; ar[13] = "I'm still pushing for The Fumblethingy to be formed"; ar[14] = "Secretryan28 leads in bomb scores in the UK with 113 (to date)"; ar[15] = "Does the term 'bonking' come from Scouts in TF2?"; ar[16] = "UK Grifball- Served with tea and crumpets"; ar[17] = "UK Grifball- We've got this or croquet"; ar[18] = "UK Grifball- The best thing sinec the cork pipe"; ar[19] = "Wales is the best Grifballing nation";
function getMessage(){ var now = new Date(); var sec = now.getSeconds(); var random = document.getElementById("random"); random.value="Here's somthing for ya: " + ar[sec % 20]; } getMessage(); </SCRIPT> </Body> </HTML>