...

View Full Version : Why does this not output?



thenextbesthang
12-18-2006, 12:47 AM
Here is the code:

assume album is known, that it is a big array with the first group (position 0, 5, 10..) being the album number, the second group (position 1, 6, 11...) being the artist, the third group (position 2, 7, 12...) being the genre, the fourth group (position 3, 8, 13...) being the album picture, the 5th group (position 4, 9, 14...) being the song.
There are any number of albums
I want to create an array where in each element, I store an array of songs. No, for using objects is innefficient for this - no objects! Why is this code not alertying anything?


function opt_click()
{

var mydiv = document.getElementById("div1");
var myslt = document.getElementById("mymusic");
var art_sel = new Array();
var song_out = new Array();
var genre_out = new Array();
var image_out = new Array();
var m;


for(i=0;i<myslt.options.length;i++)
{
if(myslt.options[i].selected)
{
m = myslt.options[i].value;
art_sel.push(m);
}
}

for(j=0;j<art_sel.length;j++)
{
for(var k=0;i<album.length;i+=album_size)
{
var g = album[k];
var found=false;
{
if(album[k+1] == art_sel[j])
{
found = true;
var song_at = new Array();
song_at.push(album[k+4]);
song_out.push(song_at);
}
}
}
}

for(i=0;i<song_out.length;i++)
{
for(s=0;s<song_at.length;s++)
{
window.alert(song_at[s]);
}
}
}

koyama
12-18-2006, 04:26 AM
Can we see a live example? -Or the rest of your code.

Where is album defined? And album_size? Are you sure that your function opt_click() is getting these values correctly?

dumpfi
12-18-2006, 06:24 PM
No, for using objects is innefficient for this - no objects!Arrays in JavaScript are objects with additional array-specific methods. So I don't think they can be any more efficient than regular objects.

dumpfi



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum