confused: Not sure why this function works the first time but doesn't the second or third time. Any advice greatly appreciated. This is called with ul li tag onclick which sends an ajax get call to the database so the array can only contain upto 3 matching indexes. I should be able to urencode the array.join(' ') and send it to the server for pagination technique with ajax Get request, unfortunatley after the first round the array.join will produce 'art' 'art' 'silver'. Which I could break down on the server side with the php file but I would preffer that the array arrived as per the function. ie.
eather of the following

  • 'art'
  • 'art' 'art'
  • 'art' 'art' 'art'

not

  • 'art'
  • 'art' 'silver'
  • 'silver' 'art' 'silvergold'

Function Counter()

function counter()
{
if(count.length==1)
{
return;
}
else if(count.length==2 && count[0]!==count[1])
{
count.shift();
alert(count.join(' '));//Demonstrates 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();
alert(count.join(' '));
}
else if(count.length>3)
{
count.shift();
alert(count.join(' '));
}
}

Not sure why it doesn't work beyond first time arround:eek:. Thanks again for any advice.

:confused: Not sure why this function works the first time but doesn't the second or third time. Any advice greatly appreciated. This is called with ul li tag onclick which sends an ajax get call to the database so the array can only contain upto 3 matching indexes. I should be able to urencode the array.join(' ') and send it to the server for pagination technique with ajax Get request, unfortunatley after the first round the array.join will produce 'art' 'art' 'silver'. Which I could break down on the server side with the php file but I would preffer that the array arrived as per the function. ie.
eather of the following

  • 'art'
  • 'art' 'art'
  • 'art' 'art' 'art'

not

  • 'art'
  • 'art' 'silver'
  • 'silver' 'art' 'silvergold'

Function Counter()

function counter()
{
if(count.length==1)
{
return;
}
else if(count.length==2 && count[0]!==count[1])
{
count.shift();
alert(count.join(' '));//Demonstrates 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();
alert(count.join(' '));
}
else if(count.length>3)
{
count.shift();
alert(count.join(' '));
}
}

Not sure why it doesn't work beyond first time arround:eek:. Thanks again for any advice.

OK. I have it working better. I had to call the function 'counter()' twice, once at the begining of the onclick then at the end. It seems to work like a dream now. Hope I can pass the array.join in the Get httprequest!!!