Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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]);
    		}
    	}
    }

  • #2
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    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?

  • #3
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •