tags:

views:

63

answers:

1

Hi,

we have a website where the users occasionally gets invalid index when trying to move some items from one list box to another. when we try to do the same thing it doesn't happen. so we are not sure how that is happening. It seems like the script is trying to access an element in the array that doesn't exist or something like that. Is there a way to check if the array item to avoid this error?

Thanks, sridhar.

A: 
array=new Array();
index=0;
if(array[index]!=undefined) ///Now users are happy because it gives true also if that element is 0 or ''

That condition is true only if an element in array with index position exists

mck89
This isn't PHP, but Javascript. It does provide the answer though
Colin
And is not a falsy value like 0, "" or null.
Ionuț G. Stan
sorry i use $ but it works in js, i have tested it
mck89