Tech Support Guy banner
Status
Not open for further replies.
1 - 5 of 5 Posts

·
Registered
Joined
·
6 Posts
Discussion Starter · #1 ·
Code:
<html>
<HEAD>

<Script language="text/JavaScript">
// Random message spouter  - Spout a message

if(!TRUE) {const FALSE = 0; const TRUE = !FALSE;};

var msg = new Array();
msg[1]= "7th Legion";
msg[2]= "Alone in the Dark (1992)";
msg[3]= "America's Army";
msg[4]= "American McGee's Alice";
msg[5]= "Anarchy Online";
msg[6]= "Asheron's Call 2: Fallen Kings";
msg[7]= "BioShock";
msg[8]= "The Black Mirror";
msg[9]= "Blade Runner";
msg[10]= "Blair Witch Volume 1: Rustin Parr";
msg[11]= "Blair Witch Volume 2: The Legend of Coffin Rock";
msg[12]= "Blair Witch Volume 3: The Elly Kedward Tale";
msg[13]= "Carmageddon";
msg[14]= "Carmageddon 2: Carpocalypse Now";
msg[15]= "Carmageddon 3: TDR 2000";
msg[16]= "Carmageddon Splat Pack";
msg[17]= "Chrono Cross";
msg[18]= "Clive Barker's Jericho";
msg[19]= "Command & Conquer 3: Kane's Wrath";
msg[20]= "Command & Conquer 3: Tiberium Wars";
msg[21]= "Command & Conquer The First Decade";
msg[22]= "Dark Reign: The Future of War";
msg[23]= "Deadly Tide";
msg[24]= "Delta Force 2";
msg[25]= "Descent";
msg[26]= "Deus Ex";
msg[27]= "Diablo";
msg[28]= "Diablo II: Lord of Destruction";
msg[29]= "Die Hard Trilogy";
msg[30]= "Dirge of Cerberus: Final Fantasy VII";
msg[31]= "Doom 3";
msg[32]= "Doom 3: Resurrection of Evil";
msg[33]= "Duke Nukem 3D";
msg[34]= "Duke Nukem II";
msg[35]= "Duke Nukem: Manhattan Project";
msg[36]= "Dungeon Keeper 2";
msg[37]= "Earth & Beyond";
msg[38]= "Fable: The Lost Chapters";
msg[39]= "Final Fantasy Chronicles";
msg[40]= "Final Fantasy IX";
msg[41]= "Final Fantasy Origins";
msg[42]= "Final Fantasy VII";
msg[43]= "Final Fantasy VIII";
msg[44]= "Final Fantasy X";
msg[45]= "Final Fantasy X-2";
msg[46]= "The Forgotten";
msg[47]= "Frankenstein: Through the Eyes of the Monster";
msg[48]= "From Dusk Till Dawn";
msg[49]= "Giants: Citizen Kabuto";
msg[50]= "God of war";
msg[51]= "God of war 2";
msg[52]= "Hard Truck 2";
msg[53]= "Hitman Trilogy";
msg[54]= "The House of the Dead";
msg[55]= "Interstate '76";
msg[56]= "The Journeyman Project 3: Legacy of Time";
msg[57]= "Jumpgate: The Reconstruction Initiative";
msg[58]= "KKND Xtreme";
msg[59]= "King's Quest I: Quest For The Crown (1990)";
msg[60]= "Legacy of Kain: Defiance";
msg[61]= "Lineage: The Blood Pledge";
msg[62]= "The Longest Journey";
msg[63]= "Lost Planet: Extreme Condition";
msg[64]= "MDK";
msg[65]= "MDK 2";
msg[66]= "The Maw";
msg[67]= "MechCommander";
msg[68]= "Metal Gear Solid";
msg[69]= "Metal Gear Solid 2: Sons of Liberty";
msg[70]= "Metal Gear Solid 3: Snake Eater";
msg[71]= "Microsoft Golf 1998 Edition";
msg[72]= "Monster Truck Madness";
msg[73]= "Mortal Kombat: Deception";
msg[74]= "Myst";
msg[75]= "Myst III: Exile";
msg[76]= "Myst IV: Revelation";
msg[77]= "Myst V: End of Ages";
msg[78]= "Myth: The Fallen Lords";
msg[79]= "The Need for Speed";
msg[80]= "Need for Speed III: Hot Pursuit";
msg[81]= "The New Adventures of the Time Machine";
msg[82]= "Nibiru: Age of Secrets";
msg[83]= "Oddworld: Abe's Exoddus";
msg[84]= "Parasite Eve";
msg[85]= "Populous: The Beginning";
msg[86]= "Quake II";
msg[87]= "Quake Mission Pack No. 1: Scourge of Armagon";
msg[88]= "Quake Mission Pack No. 2: Dissolution of Eternity";
msg[89]= "Riven: The Sequel to Myst";
msg[90]= "The Secret of Monkey Island";
msg[91]= "SiN";
msg[92]= "SiN Episodes: Emergence";
msg[93]= "SimCoaster";
msg[94]= "The Sims Online";
msg[95]= "Soldier of Fortune: Platinum Edition";
msg[96]= "Sonic Mega Collection Plus";
msg[97]= "Star Trek: Starfleet Command";
msg[98]= "Street Fighter Alpha";
msg[99]= "Tachyon: The Fringe";
msg[100]= "Terminal Velocity";
msg[101]= "Tomb Raider: The Last Revelation";
msg[102]= "Total Annihilation";
msg[103]= "Traitors Gate";
msg[104]= "Ultima I: The First Age of Darkness";
msg[105]= "Ultima Online: Renaissance";
msg[106]= "Ultima Online: Age of Shadows";
msg[107]= "Ultima Underworld: The Stygian Abyss";
msg[108]= "Vampire: The Masquerade - Redemption";
msg[109]= "Warcraft II: Beyond the Dark Portal";
msg[110]= "Wing Commander";
msg[111]= "The Witcher Enhanced EditionWolfenstein 3D";
msg[112]= "X-COM: UFO Defense";
msg[113]= "XS";

function spout_message()
{
	var i = Math.round(200*Math.random()); 
	spout_out.value=msg[i];
}

</script>
</head><body>

<form>
<input type="button" onClick="spout_message()" id="spout_btn" name="spout_btn" value="spout">
<input type="text" id="spout_out" name="spout_out" value="Spout out a name">

</form>
</body>
</html>
now that you've seen my code, can you help me out? no matter what browser I use I can't seem to get that pesky onClick to work. It's supposed to send a random message to the value of the edit box. I know this isn't sloppy code, and it looks like it really should work, but there's function call problems. Error says "spout_message is not defined" same on Chrome and Firefox. I'm not going to go and try a sloppy browser like IE, just need the thing to work.
 

·
Registered
Joined
·
3,625 Posts
Change

<Script language="text/JavaScript">

to

<script type="text/javascript">

And yeah, that code isn't too great. Building an array like that isn't too wise. And your array randomizer doesn't work right.
 

·
Registered
Joined
·
6 Posts
Discussion Starter · #3 ·
I'm an old QBasic user, and this was just supposed to be a quick little script for a friend who doesn't understand JavaScript. I wanted him to be able to add messages on his own. And what's wrong with the Qbasic style randomizer shortcut (besides that it rounds up 200 times a random number)? I looked around w3schools.com and couldn't find anything better.
 

·
Registered
Joined
·
3,625 Posts
That's the only problem with the randomizer.

A better way to build your array:

Code:
var myscript = [
	"Item1",
	"Item2",
	"Item3",
	"Item4",
	"Item5",
	"Item6",
	"Item7"
];
 
1 - 5 of 5 Posts
Status
Not open for further replies.
Top