SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Threaded View

  1. #1
    SitePoint Addict
    Join Date
    Dec 2009
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Array function only works first time?

    Don't understand why but this array function only works the first time arround. The idea is to send the array.join(' ') with Ajax Get to server for pagination technique. uriencoded array.join(' ') should be
    1. 'art'
    2. 'art' 'art'
    3. 'art' 'art' 'art'

    Not
    1. 'art'
    2. 'silver' 'art'
    3. 'silvergold' 'silver' 'art'

    Counter Function
    Code:
    function counter()
    {
    if(count.length==1)
    {
    return;
    }
    else if(count.length==2 && count[0]!==count[1])
    {
    count.shift();
    alert(count.join(' '));//Demonstrate flaw
    }
    else if(count.length==3 && count[0]!==count[1])
    {
    count.shift();
    alert(count.join(' '));
    }
    else if(count.length==3 && count[1]!==count[2])
    {
    count.shift();
    count.shift();//should get rid of index 0 and 1, does first time?
    alert(count.join(' '));
    }
    else if(count.length>3)
    {
    count.shift();//gaurenty max length of 3?
    }
    }
    Any advice greatly appreciated.
    Last edited by Heinz Stapff; Apr 21, 2012 at 10:40. Reason: gaurenty max length of 3?


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
  •