Results 1 to 4 of 4

Thread: Up-Down Scroller displays 'undefined' after last item displayed

  1. #1
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Up-Down Scroller displays 'undefined' after last item displayed

    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.

    Thanks....Rick..

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Please post a link to the page on your site that contains the problematic script so we can check it out.
    DD Admin

  3. #3
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The test page is here

    http://66.147.244.195/~posffosc/suic....com/index.php

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

    ...Rick...
    Last edited by jscheuer1; 11-13-2010 at 05:53 AM. Reason: remove duplicate link

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The pausecontent and pausecontent2 you've defined are Objects. The script is expecting Arrays. Add this highlighted bit to the script code as shown:

    Code:
    // -------------------------------------------------------------------
    // initialize()- Initialize scroller method.
    // -Get div objects, set initial positions, start up down animation
    // -------------------------------------------------------------------
    
    pausescroller.prototype.initialize=function(){
    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)){
    			xlat.push(c[p]);
    		} else if (!isNaN(p)){
    			xlat[++cnt] = c[p];
    		}
    	}
    	this.content = xlat;
    }
    this.tickerdiv=document.getElementById(this.tickerid)
    this.visiblediv=document.getElementBy . . .
    Or alternatively you could skip that and make pausecontent and pausecontent2 true arrays.
    Last edited by jscheuer1; 11-13-2010 at 10:09 AM. Reason: make addition backward compatible, add alternative
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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