/    Sign up×
Community /Pin to ProfileBookmark

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’;
}
}
}
[/CODE]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@antaresauthorAug 12.2010 — Anyone have any ideas why firebug would be having an error with this line?
Copy linkTweet thisAlerts:
@patrx-7Aug 12.2010 — Just a quick note that may lead somewhere. It seems to me that [CODE] for( i; i < i+16; i++ )[/CODE] 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++ )[/CODE]


Patrick Carlo-Hickman

http://AllegroConsultants.com/opensource
Copy linkTweet thisAlerts:
@antaresauthorAug 12.2010 — 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
Copy linkTweet thisAlerts:
@patrx-7Aug 12.2010 — 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
×

Success!

Help @antares spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...