1

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.

1 Answer 1

1
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

Sign up to request clarification or add additional context in comments.

2 Comments

This isn't PHP, but Javascript. It does provide the answer though
And is not a falsy value like 0, "" or null.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.