PDA

View Full Version : variable undefined... but i swear i defined it :D


renoboi
03-12-2003, 03:06 PM
ok... i can't for the life of me figure out why this won't work.
it says Error: 'image' undefined line 61... but it looks to me like image is defined. somebody help me?


<html>
<head>
<script language="JavaScript">
<!--
var imagenumber = 20 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;

var images = new Array
images[1] = "/sound/001.asx"
images[2] = "/sound/002.asx"
images[3] = "/sound/003.asx"
images[4] = "/sound/004.asx"
images[5] = "/sound/005.asx"
images[6] = "/sound/006.asx"
images[7] = "/sound/007.asx"
images[8] = "/sound/008.asx"
images[9] = "/sound/009.asx"
images[10] = "/sound/010.asx"
images[11] = "/sound/011.asx"
images[12] = "/sound/012.asx"
images[13] = "/sound/013.asx"
images[14] = "/sound/014.asx"
images[15] = "/sound/015.asx"
images[16] = "/sound/016.asx"
images[17] = "/sound/017.asx"
images[18] = "/sound/018.asx"
images[19] = "/sound/019.asx"
images[20] = "/sound/020.asx"
var image = images[rand1]

var names = new Array
names[1] = "Girls And Boys by Blur"
names[2] = "All I Wanna Do by Cheryl Crow"
names[3] = "Always Forever by Southern Express Trio"
names[4] = "Breathe by Faith Hill"
names[5] = "Digital Love by Daft Punk"
names[6] = "Dream Weaver by Erin Hamilton"
names[7] = "Higher by Creed"
names[8] = "I Drive Myself Crazy by *NSYNC"
names[9] = "It's All Coming Back To Me Now by Celine Dion"
names[10] = "Karma Chameleon by Boy George"
names[11] = "Lady Marmalade by Christina, Lil' Kim, Mya, and Pink"
names[12] = "The Middle by Jimmy Eat World"
names[13] = "One More Time by Daft Punk"
names[14] = "Set You Free by N-Trance"
names[15] = "Smooth Criminal by Alien Ant Farm"
names[16] = "Someone Else's Dream by Faith Hill"
names[17] = "Spider Webs by No Doubt"
names[18] = "Still The One by Shania Twain
names[19] = "Walking On Sunshine by Katrina and The Waves"
names[20] = "Wild One by Faith Hill"
var name = names[rand1]
// -->
</script>
</head>

<body>

<script language="JavaScript">
<!--
document.write('You are listening to a clip from ' + name + '.')
document.write('<embed src="' + image + '" hidden=false autoplay=true>')
// -->
</script>
</body>
</html>

Roy Sinclair
03-12-2003, 03:19 PM
Put the closing quote on this line:

names[18] = "Still The One by Shania Twain

Then the problem disappears.

renoboi
03-12-2003, 10:59 PM
omg... thank you so much. i knew it was sumthin stupid like that.