Jump to content

Add to counter


son

Recommended Posts

I have a counter, which shows the number of the image out of all images to be displayed. Once it goes beyond 10 instead of displaying '11' it displays '110' and continues to add up as '2110', '32110', '432110' etc. The relevant code is:temp=inlineSlides.counterLabel.replace(/#/,o.currentSlide+1);Is '+1' not the right way to add to a counter?Son

Link to comment
Share on other sites

Hi, I was going to suggest parseInt also, but how come it works until it gets to 10?
It is actually an integer, I had it a bit before in script:uls.currentSlide=0;Is there any other reason why this would not work? I could post the whole script, but it is rather long...Son
Link to comment
Share on other sites

According to what I see, the pattern adds the next biggest number to the beginning. e.g. (0)10, 110, 2110, 32110, 432110, 5432110, etc. That pattern clearly indicates that a string is being concatenated onto another string. That's about all I can say at this point, there is a line somewhere that is adding a number to the counter and it's using string concatenation to do it. Look for the parts in the script where you change the value of the counter, that's where the problem is.

Link to comment
Share on other sites

According to what I see, the pattern adds the next biggest number to the beginning. e.g. (0)10, 110, 2110, 32110, 432110, 5432110, etc. That pattern clearly indicates that a string is being concatenated onto another string. That's about all I can say at this point, there is a line somewhere that is adding a number to the counter and it's using string concatenation to do it. Look for the parts in the script where you change the value of the counter, that's where the problem is.
I found now the problem.The offending line is:counterText.nodeValue=counterText.nodeValue.replace(/\d/,count+1);As \d stands for one digit, the counter script won't work for 10 and below. I amended the reg expression tocounterText.nodeValue=counterText.nodeValue.replace(/[0-9]{1,2}/,count+1);and it works:-)SonReason for edit: Found solution minutes after post
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...