View Full Version : Up-Down Scroller displays 'undefined' after last item displayed

11-12-2010, 12:28 AM
1) Script Title: Pausing up-down scroller

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex2/crosstick.htm

3) Describe problem: When the script gets to the end of the array, it appears that it is not resetting back to the beginning of the array. I get a message "undefined" scrolling in the message area.

I'm just past being a beginner in Javascript, but I can't find where the array pointer is set back to the beginning if the last item in the array is being displayed. I am assuming that the array pointer being 'past' the end of the array is the cause of the display of 'undefined'.

Suggestions? I've already double-checked that the code is correct according to the code on your page.


11-12-2010, 07:04 AM
Please post a link to the page on your site that contains the problematic script so we can check it out.

11-13-2010, 01:26 AM
The test page is here

There is a lot of data displayed, so it takes a while to get to the point where the 'undefined' is displayed.


11-13-2010, 09:47 AM
The pausecontent and pausecontent2 you've defined are Objects. The script is expecting Arrays. Add this highlighted bit to the script code as shown:

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

if(this.content.constructor === Object){
var p, xlat = [], c = this.content, cnt = -1;
for (p in c){
if(c.hasOwnProperty && c.hasOwnProperty(p) && !isNaN(p)){
} else if (!isNaN(p)){
xlat[++cnt] = c[p];
this.content = xlat;
this.visiblediv=document.getElementBy . . .

Or alternatively you could skip that and make pausecontent and pausecontent2 true arrays.