www.webdeveloper.com
Results 1 to 5 of 5

Thread: firefox and firebug error

  1. #1
    Join Date
    Jul 2010
    Location
    Texas
    Posts
    76

    firefox and firebug error

    So I have a function that gets called when you press an arror which will update 16 img src attributes. Odd thing is, it loads them properly, however, the checkboxes which determines if a client/user likes, or in this case makes them a favorite doesn't update or even load the initial set. I was wondering what was wrong. Any ideas?

    Firebug tells me its the line with the *****

    Code:
    function updateThumbnails()
    {
    	var i = (currentPage-1)*16;
    	var x = 0;
    	if( currentPage != totalPages )
    	{
    		for( i; i < i+16; i++ )
    		{
    			x = i-(16*(currentPage-1));
    			******document.getElementById( "tb_" + x ).src = thumbnail_dir + thumbnails[i];*******
    			document.getElementById( "fav_" + x ).disabled = false;
    			document.getElementById( "fav_" + x ).style.display = 'inline';
    			document.getElementById( "fav_" + x ).checked = false;
    			if( favorites[i] )
    			{
    				document.getElementById( "fav_" + x ).checked = true;
    			}
    		}
    	}
    	else
    	{
    		
    		for( i; i < thumbnails.length; i++ )
    		{
    			x = i-(16*(currentPage-1));
    			document.getElementById( "tb_" + x ).src = thumbnail_dir + thumbnails[i];
    			document.getElementById( "fav_" + x ).checked = false;
    			if( favorites[i] )
    			{
    				document.getElementById( "fav_" + x ).checked = true;
    			}
    		}
    		for( var k = thumbnails.length % 16; k < 16; k++)
    		{
    			document.getElementById( "tb_" + k ).src = "http://www.roderickpena.com/images/layout/blank.png";
    			document.getElementById( "fav_" + k ).disabled = true;
    			document.getElementById( "fav_" + k ).style.display = 'none';
    		}
    	}
    }

  2. #2
    Join Date
    Jul 2010
    Location
    Texas
    Posts
    76
    Anyone have any ideas why firebug would be having an error with this line?

  3. #3
    Join Date
    Jun 2008
    Posts
    23
    Just a quick note that may lead somewhere. It seems to me that
    Code:
    		for( i; i < i+16; i++ )
    results in an infinite loop (i < i+16 will always be true). The infinite loop would eventually lead to getElementById( "tb_" + x ) not finding an element, and to thumbnails[i] going out of bounds of the array.

    You might try:
    Code:
    		var endLoop = i + 16;
    		for( i; i < endLoop; i++ )
    Patrick Carlo-Hickman
    http://AllegroConsultants.com/opensource

  4. #4
    Join Date
    Jul 2010
    Location
    Texas
    Posts
    76
    Ahh, yeah that does make sense. However, firefox still doesn't update the checkboxes. I didn't know this but I had put false for the async with the httprequest when grabbing the favorites. Guess firefox doesn't like that.

    Thanks for the reply pat

  5. #5
    Join Date
    Jun 2008
    Posts
    23
    Do the checkboxes have an id attribute defined? In IE, getElementById will find the element by the name attribute, if the id attribute doesn't exist. FireFox will not do this.

    Just another thought.

    Patrick Carlo-Hickman
    http://AllegroConsultants.com/opensource

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles