Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-17-2006, 11:47 PM   PM User | #1
thenextbesthang
New Coder

 
Join Date: Oct 2006
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
thenextbesthang is an unknown quantity at this point
Why does this not output?

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?
Code:
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]);
		}
	}
}
thenextbesthang is offline   Reply With Quote
Old 12-18-2006, 03:26 AM   PM User | #2
koyama
Senior Coder

 
koyama's Avatar
 
Join Date: Dec 2006
Location: Copenhagen, Denmark
Posts: 1,246
Thanks: 1
Thanked 5 Times in 5 Posts
koyama will become famous soon enough
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?
koyama is offline   Reply With Quote
Old 12-18-2006, 05:24 PM   PM User | #3
dumpfi
Regular Coder

 
Join Date: Jun 2004
Posts: 565
Thanks: 0
Thanked 18 Times in 18 Posts
dumpfi will become famous soon enough
Quote:
Originally Posted by thenextbesthang View Post
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
__________________
"Failure is not an option. It comes bundled with the software."
....../)/)..(\__/).(\(\................../)_/)......
.....(-.-).(='.'=).(-.-)................(o.O)...../<)
....(.).(.)("}_("}(.)(.)...............(.)_(.))¯/.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Little did the bunnies suspect that one of them was a psychotic mass murderer with a 6 ft. axe.
dumpfi is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:13 AM.


Advertisement
Log in to turn off these ads.